Changeset 3343442
- Timestamp:
- 08/12/2025 10:27:51 AM (6 months ago)
- Location:
- garantie-sgr/trunk
- Files:
-
- 2 edited
-
garantie-sgr.php (modified) (8 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
garantie-sgr/trunk/garantie-sgr.php
r3343431 r3343442 4 4 * Plugin URL: https://uprise.ro 5 5 * Description: Extensie WooCommerce pentru sistemul garanție-returnare SGR. 6 * Version: 2.0. 26 * Version: 2.0.3 7 7 * Author: Eduard V. Doloc 8 8 * Author URI: https://uprise.ro … … 12 12 * WC requires at least: 7.9 13 13 * WC tested up to: 10.0 14 * Stable tag: 2.0. 214 * Stable tag: 2.0.3 15 15 * Requires Plugins: woocommerce 16 16 * License: GPLv2 or later … … 123 123 'post_type' => 'product', 124 124 'post_status' => 'publish', 125 // Ensure product type exists *during* save_post so wc_get_product() works126 125 'tax_input' => array( 127 126 'product_type' => array( 'simple' ), … … 134 133 } 135 134 136 // Core Woo metas (no HTML, so sanitize_text_field is fine for scalar metas)135 // Core Woo metas 137 136 update_post_meta( $product_id, '_sku', $sgr_sku ); 138 137 update_post_meta( $product_id, '_price', '0.50' ); … … 144 143 // Hide from catalog (product_visibility term) 145 144 if ( taxonomy_exists( 'product_visibility' ) ) { 146 // Don’t touch other terms, just add exclude-from-catalog147 145 wp_set_object_terms( $product_id, 'exclude-from-catalog', 'product_visibility', true ); 148 146 } … … 174 172 175 173 // Update path / repairs when users update without re-activating. 176 // Run only after WooCommerce is fully initialized.177 174 add_action( 'woocommerce_init', function () { 178 175 if ( ! class_exists( 'WC_Product_Simple' ) || ! function_exists( 'wc_get_product_id_by_sku' ) ) { … … 186 183 $needs = false; 187 184 188 // If activation set a pending flag, run now.189 185 if ( $pending_setup ) { 190 186 $needs = true; 191 187 } 192 193 // On version change or missing product ID, run now.194 188 if ( $stored_version !== GARANTIE_SGR_VERSION ) { 195 189 $needs = true; … … 200 194 201 195 if ( $needs ) { 202 garantie_sgr_product_create(); 203 update_option( 'garantie_sgr_version', GARANTIE_SGR_VERSION ); 204 delete_option( 'garantie_sgr_pending_setup' ); 196 // Defer actual creation until after Woo has fully initialized. 197 add_action( 'wp_loaded', function () { 198 $created_id = garantie_sgr_product_create(); 199 if ( $created_id ) { 200 update_option( 'garantie_sgr_version', GARANTIE_SGR_VERSION ); 201 delete_option( 'garantie_sgr_pending_setup' ); 202 } 203 }, 20 ); 205 204 } 206 205 }, 20 ); -
garantie-sgr/trunk/readme.txt
r3343431 r3343442 8 8 WC requires at least: 7.9 9 9 WC tested up to: 10.0 10 Stable tag: 2.0. 210 Stable tag: 2.0.3 11 11 Requires Plugins: woocommerce 12 12 License: GPLv2 or later
Note: See TracChangeset
for help on using the changeset viewer.