Changeset 2264622
- Timestamp:
- 03/20/2020 04:15:21 PM (6 years ago)
- Location:
- force-default-variant-for-woocommerce
- Files:
-
- 8 added
- 4 edited
-
tags/1.5.1 (added)
-
tags/1.5.1/functions.php (added)
-
tags/1.5.1/includes (added)
-
tags/1.5.1/includes/clear-removal.php (added)
-
tags/1.5.1/includes/settings.php (added)
-
tags/1.5.1/includes/variations.php (added)
-
tags/1.5.1/readme.txt (added)
-
tags/1.5.1/woo-force-default-variant.php (added)
-
trunk/includes/settings.php (modified) (2 diffs)
-
trunk/includes/variations.php (modified) (5 diffs)
-
trunk/readme.txt (modified) (4 diffs)
-
trunk/woo-force-default-variant.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
force-default-variant-for-woocommerce/trunk/includes/settings.php
r2199009 r2264622 6 6 add_filter( 'woocommerce_get_sections_products', 'hpy_woo_add_section' ); 7 7 function hpy_woo_add_section( $sections ) { 8 $sections['hpy_variants'] = __( 'Variants', ' hpy_wdv' );8 $sections['hpy_variants'] = __( 'Variants', 'force-default-variant-for-woocommerce' ); 9 9 return $sections; 10 10 } … … 21 21 $settings_variant = array(); 22 22 23 $settings_variant[] = array( 'name' => __( 'Default Variant Settings', ' hpy_wdv' ), 'type' => 'title', 'id' => 'hpy_variants' );23 $settings_variant[] = array( 'name' => __( 'Default Variant Settings', 'force-default-variant-for-woocommerce' ), 'type' => 'title', 'id' => 'hpy_variants' ); 24 24 25 25 $settings_variant[] = array( 26 'name' => __( 'Sort by:', ' hpy_wdv' ),27 'desc_tip' => __( 'Change how you want the default variant to be sorted.', ' hpy_wdv' ),26 'name' => __( 'Sort by:', 'force-default-variant-for-woocommerce' ), 27 'desc_tip' => __( 'Change how you want the default variant to be sorted.', 'force-default-variant-for-woocommerce' ), 28 28 'id' => 'hpy_variant_sort', 29 29 'type' => 'select', 30 30 'options' => array( 31 'position' => __( 'Position', ' hpy_wdv' ),32 'id' => __( 'ID', ' hpy_wdv' ),33 'price-low' => __( 'Price Low -> High', ' hpy_wdv' ),34 'price-high' => __( 'Price High -> Low', ' hpy_wdv' ),31 'position' => __( 'Position', 'force-default-variant-for-woocommerce' ), 32 'id' => __( 'ID', 'force-default-variant-for-woocommerce' ), 33 'price-low' => __( 'Price Low -> High', 'force-default-variant-for-woocommerce' ), 34 'price-high' => __( 'Price High -> Low', 'force-default-variant-for-woocommerce' ), 35 35 ), 36 36 'css' => 'min-width:300px;', 37 'desc' => __( '<p>How do you want to sort the variations</p>', ' hpy_wdv' ),37 'desc' => __( '<p>How do you want to sort the variations</p>', 'force-default-variant-for-woocommerce' ), 38 38 ); 39 39 40 40 $settings_variant[] = array( 41 'name' => __( 'Then Sort by:', ' hpy_wdv' ),42 'desc_tip' => __( 'If any Variations are the same in the above sorting method you can define a secondary method to sort them.', ' hpy_wdv' ),41 'name' => __( 'Then Sort by:', 'force-default-variant-for-woocommerce' ), 42 'desc_tip' => __( 'If any Variations are the same in the above sorting method you can define a secondary method to sort them.', 'force-default-variant-for-woocommerce' ), 43 43 'id' => 'hpy_variant_then_sort', 44 44 'type' => 'select', 45 45 'options' => array( 46 'default' => __( 'Position', ' hpy_wdv' ),47 'then_sales' => __( 'Sales', ' hpy_wdv' ),48 'then_id' => __( 'ID', ' hpy_wdv' ),49 'then_stock' => __( 'Stock Levels', ' hpy_wdv' ),46 'default' => __( 'Position', 'force-default-variant-for-woocommerce' ), 47 'then_sales' => __( 'Sales', 'force-default-variant-for-woocommerce' ), 48 'then_id' => __( 'ID', 'force-default-variant-for-woocommerce' ), 49 'then_stock' => __( 'Stock Levels', 'force-default-variant-for-woocommerce' ), 50 50 ), 51 51 'css' => 'min-width:300px;', 52 'desc' => __( '', ' hpy_wdv' ),52 'desc' => __( '', 'force-default-variant-for-woocommerce' ), 53 53 ); 54 54 55 55 $settings_variant[] = array( 56 'name' => __( 'Stock Limit:', ' hpy_wdv' ),57 'desc_tip' => __( 'Check the stock limit of the variant before displaying. If this is not set the Plugin will still check for the overall stock status.', ' hpy_wdv' ),56 'name' => __( 'Stock Limit:', 'force-default-variant-for-woocommerce' ), 57 'desc_tip' => __( 'Check the stock limit of the variant before displaying. If this is not set the Plugin will still check for the overall stock status.', 'force-default-variant-for-woocommerce' ), 58 58 'id' => 'hpy_variant_stockLimit', 59 59 'type' => 'text', 60 'desc' => __( '<p>Skip Variant if Stock level is below this limit</p>', ' hpy_wdv' ),60 'desc' => __( '<p>Skip Variant if Stock level is below this limit</p>', 'force-default-variant-for-woocommerce' ), 61 61 ); 62 62 63 63 $settings_variant[] = array( 64 'name' => __( 'Keep manually set defaults:', ' hpy_wdv' ),65 'desc_tip' => __( 'If you have already set manual defaults for some products and want to keep those select this box. Otherwise Force Default Variant will overwrite that option.', ' hpy_wdv' ),64 'name' => __( 'Keep manually set defaults:', 'force-default-variant-for-woocommerce' ), 65 'desc_tip' => __( 'If you have already set manual defaults for some products and want to keep those select this box. Otherwise Force Default Variant will overwrite that option.', 'force-default-variant-for-woocommerce' ), 66 66 'id' => 'hpy_variant_respect', 67 67 'std' => 'no', // WooCommerce < 2.0 68 68 'default' => 'no', // WooCommerce >= 2.0 69 69 'type' => 'checkbox', 70 'desc' => __( '<p>Respect the Product\'s Default if it is already set.</p>', ' hpy_wdv' ),70 'desc' => __( '<p>Respect the Product\'s Default if it is already set.</p>', 'force-default-variant-for-woocommerce' ), 71 71 ); 72 72 73 73 $settings_variant[] = array( 74 'name' => __( 'Disable auto-removal of \'Select Option\' text ', ' hpy_wdv' ),75 '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' ),74 'name' => __( 'Disable auto-removal of \'Select Option\' text ', 'force-default-variant-for-woocommerce' ), 75 '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.', 'force-default-variant-for-woocommerce' ), 76 76 'id' => 'hpy_disabled_auto_remove_dropdown', 77 77 'std' => 'no', // WooCommerce < 2.0 78 78 'default' => 'no', // WooCommerce >= 2.0 79 79 'type' => 'checkbox', 80 'desc' => __( '<p>Re-enable \'Select Option\' text globally, manually set defaults will still apply.</p>', ' hpy_wdv' ),80 'desc' => __( '<p>Re-enable \'Select Option\' text globally, manually set defaults will still apply.</p>', 'force-default-variant-for-woocommerce' ), 81 81 ); 82 82 -
force-default-variant-for-woocommerce/trunk/includes/variations.php
r2198872 r2264622 3 3 add_filter( 'woocommerce_product_get_default_attributes', 'hpy_fdv_default_attribute', 10, 1 ); 4 4 add_filter( 'woocommerce_dropdown_variation_attribute_options_html', 'hpy_fdv_remove_dropdown_option_html', 12, 2 ); 5 add_filter( 'woocommerce_dropdown_variation_attribute_options_args', 'hpy_fdv_attribute_args_v2', 10, 1 ); 5 6 } else { 6 7 add_filter( 'woocommerce_dropdown_variation_attribute_options_args', 'hpy_fdv_attribute_args', 10, 1 ); … … 54 55 55 56 /** 57 * Re-order the variations depending on the chosen option. If nothing is set default to ID. 58 * 59 * @param array $args 60 * 61 * @return array 62 */ 63 function hpy_fdv_attribute_args_v2( $args = array() ) { 64 65 $args[ 'show_option_none' ] = false; 66 67 return $args; 68 69 } 70 71 /** 56 72 * Remove the Choose an Option HTML. 57 73 * … … 66 82 return $html; 67 83 } 84 85 return $html; 68 86 69 87 $show_option_none_text = $args['show_option_none'] ? $args['show_option_none'] : __( 'Choose an option', 'woocommerce' ); … … 95 113 $sortby = apply_filters( 'hpy_fdv_custom_sortby', !empty( get_option( 'hpy_variant_sort' ) ) ? get_option( 'hpy_variant_sort' ) : 'id' ); 96 114 $thensort = apply_filters( 'hpy_fdv_custom_then_sortby', !empty( get_option( 'hpy_variant_then_sort' ) ) ? get_option( 'hpy_variant_then_sort' ) : 'default' ); 115 $hide_oos = 'yes' == get_option( 'woocommerce_hide_out_of_stock_items' ); 97 116 98 117 if ( $respect == 'yes' && !empty( $defaults ) ) { … … 116 135 $stock_qty = $_child->get_stock_quantity(); 117 136 $sales = $_child->get_total_sales(); 118 137 $stock_status = $_child->is_in_stock(); 138 139 if ( $hide_oos && !$stock_status ) { 140 //If Hide out of Stock is set, and this variant is out of stock, then skip. 141 continue; 142 } 143 119 144 if ( $_child->get_status() == 'publish' ) { 120 145 $attributes[] = apply_filters( 'hpy_fdv_build_attribute_filter', array( 'price' => !empty($_child->get_price()) ? $_child->get_price() : '0' , 'id' => $_child->get_id(), 'position' => $position, 'sales' => $sales, 'stock_level' => $stock_qty ) ); -
force-default-variant-for-woocommerce/trunk/readme.txt
r2198876 r2264622 4 4 Requires at least: 4.2 5 5 Tested up to: 5.3 6 Stable tag: 1.5 6 Stable tag: 1.5.1 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 31 31 32 32 == Changelog == 33 = 1.5.1 = 34 * FIX - Now respects the 'Hide out of stock items' option within WooCommerce. 35 * IMPROVEMENT - Improved the ability for external translations. 36 * UPDATE - Tested up to WooCommerce 4.0+ 37 33 38 = 1.5 = 34 39 * NEW - Added in a Secondary sort function. If products have the same price you can sort them again by Stock, Sales, ID or Position … … 36 41 * UPDATE - Tested up to WordPress 5.3 37 42 * UPDATE - Tested up to WooCommerce 3.8 43 38 44 = 1.4.3 = 39 45 * NEW - Select Option will now be removed from all product dropdown by default. … … 42 48 * FIX - Default selected option field being blank on page load due to missing JS classes. 43 49 * UPDATE - Now works with WordPress 5.2 and above. 50 44 51 = 1.4.2 = 45 52 * NEW - Adding in the ability to sort by Variant Position -
force-default-variant-for-woocommerce/trunk/woo-force-default-variant.php
r2198872 r2264622 6 6 Author: HappyKite 7 7 Author URI: http://www.happykite.co.uk/ 8 Version: 1.5 8 Text Domain: force-default-variant-for-woocommerce 9 Version: 1.5.1 10 WC requires at least: 2.4 11 WC tested up to: 4.0.1 9 12 */ 10 13
Note: See TracChangeset
for help on using the changeset viewer.