Changeset 2102307
- Timestamp:
- 06/07/2019 02:44:13 PM (7 years ago)
- Location:
- force-default-variant-for-woocommerce
- Files:
-
- 8 added
- 3 edited
-
tags/1.4.3 (added)
-
tags/1.4.3/functions.php (added)
-
tags/1.4.3/includes (added)
-
tags/1.4.3/includes/clear-removal.php (added)
-
tags/1.4.3/includes/settings.php (added)
-
tags/1.4.3/includes/variations.php (added)
-
tags/1.4.3/readme.txt (added)
-
tags/1.4.3/woo-force-default-variant.php (added)
-
trunk/includes/settings.php (modified) (1 diff)
-
trunk/includes/variations.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
force-default-variant-for-woocommerce/trunk/includes/settings.php
r2063740 r2102307 54 54 'type' => 'checkbox', 55 55 'desc' => __( '<p>Respect the Product\'s Default if it is already set.</p>', 'hpy_wdv' ), 56 ); 57 58 $settings_variant[] = array( 59 'name' => __( 'Disable auto-removal of \'Select Option\' text ', 'hpy_wdv' ), 60 'desc_tip' => __( 'If you would like dropdowns to have the \'Select Option\' text by default when no product defaults are set, select this box. Force Default Variant options will still apply.', 'hpy_wdv' ), 61 'id' => 'hpy_disabled_auto_remove_dropdown', 62 'std' => 'no', // WooCommerce < 2.0 63 'default' => 'no', // WooCommerce >= 2.0 64 'type' => 'checkbox', 65 'desc' => __( '<p>Re-enable \'Select Option\' text globally, manually set defaults will still apply.</p>', 'hpy_wdv' ), 56 66 ); 57 67 -
force-default-variant-for-woocommerce/trunk/includes/variations.php
r2063740 r2102307 66 66 */ 67 67 function hpy_fdv_remove_dropdown_option_html( $html, $args ) { 68 if ( empty( $args['selected'] ) ) { 69 return $html; 70 } 71 68 //Return normal html markup if disabled_auto_remove_dropdown is enabled. 69 if ( empty( $args['selected'] ) && get_option('hpy_disabled_auto_remove_dropdown') == 'yes' ) { 70 return $html; 71 } 72 72 73 $show_option_none_text = $args['show_option_none'] ? $args['show_option_none'] : __( 'Choose an option', 'woocommerce' ); 73 $show_option_none_html = '<option value="">' . esc_html( $show_option_none_text ) . '</option>'; 74 75 $html = str_replace($show_option_none_html, '', $html); 76 74 $show_option_none_html = '<option value="">' . esc_html( $show_option_none_text ) . '</option>'; 75 76 $html = str_replace($show_option_none_html, '', $html); 77 $html = preg_replace('/(<option\b[^><]*)>/i', '$1 class="attached enabled">', $html, 1); // Adds missing JS classes -- Fixes the field appearing blank. 78 79 // If no option selected by default, set first option to selected 80 if ( empty( $args['selected'] ) ) { 81 $html = preg_replace('/(<option\b[^><]*)>/i', '$1 selected>', $html, 1); 82 } 83 77 84 return $html; 78 85 } … … 112 119 113 120 if ( $_child->get_status() == 'publish' ) { 114 $attributes[] = array( 'price' => $_child->get_price(), 'id' => $_child->get_id(), 'position' => $position );121 $attributes[] = array( 'price' => !empty($_child->get_price()) ? $_child->get_price() : '0' , 'id' => $_child->get_id(), 'position' => $position ); 115 122 } 116 123 } … … 168 175 $attributes = array_values($attributes); 169 176 170 $_prod = wc_get_product( $attributes[0]['id'] );177 $_prod = ! empty( $attributes[0]['id'] ) ? wc_get_product( $attributes[0]['id'] ) : null; 171 178 172 179 if ( empty( $_prod ) ) { -
force-default-variant-for-woocommerce/trunk/readme.txt
r2063744 r2102307 3 3 Tags: WooCommerce, Variable product, WooCommerce variant, eCommerce 4 4 Requires at least: 4.2 5 Tested up to: 5. 1.16 Stable tag: 1.4. 25 Tested up to: 5.2 6 Stable tag: 1.4.3 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 29 29 30 30 == Changelog == 31 = 1.4.3 = 32 * NEW - Select Option will now be removed from all product dropdown by default. 33 * NEW - Added new setting to toggle default 'Select Option' text 34 * FIX - Notice in /includes/variations.php:170 35 * FIX - Default selected option field being blank on page load due to missing JS classes. 36 * UPDATE - Now works with WordPress 5.2 and above. 31 37 = 1.4.2 = 32 38 * NEW - Adding in the ability to sort by Variant Position
Note: See TracChangeset
for help on using the changeset viewer.