Plugin Directory

Changeset 2264622


Ignore:
Timestamp:
03/20/2020 04:15:21 PM (6 years ago)
Author:
HappyKite
Message:

Release of Version 1.5.1

Changelog

Location:
force-default-variant-for-woocommerce
Files:
8 added
4 edited

Legend:

Unmodified
Added
Removed
  • force-default-variant-for-woocommerce/trunk/includes/settings.php

    r2199009 r2264622  
    66add_filter( 'woocommerce_get_sections_products', 'hpy_woo_add_section' );
    77function hpy_woo_add_section( $sections ) {
    8     $sections['hpy_variants'] = __( 'Variants', 'hpy_wdv' );
     8    $sections['hpy_variants'] = __( 'Variants', 'force-default-variant-for-woocommerce' );
    99    return $sections;   
    1010}
     
    2121        $settings_variant = array();
    2222
    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' );
    2424
    2525        $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' ),
    2828            'id'       => 'hpy_variant_sort',
    2929            'type'     => 'select',
    3030            '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' ),
    3535            ),
    3636            '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' ),
    3838        );
    3939       
    4040        $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' ),
    4343            'id'       => 'hpy_variant_then_sort',
    4444            'type'     => 'select',
    4545            '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' ),
    5050            ),
    5151            'css'      => 'min-width:300px;',
    52             'desc'     => __( '', 'hpy_wdv' ),
     52            'desc'     => __( '', 'force-default-variant-for-woocommerce' ),
    5353        );
    5454       
    5555        $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' ),
    5858            'id'       => 'hpy_variant_stockLimit',
    5959            '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' ),
    6161        );
    6262       
    6363        $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' ),
    6666            'id'       => 'hpy_variant_respect',
    6767            'std'     => 'no', // WooCommerce < 2.0
    6868            'default' => 'no', // WooCommerce >= 2.0
    6969            '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' ),
    7171        );
    7272       
    7373        $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' ),
    7676            'id'       => 'hpy_disabled_auto_remove_dropdown',
    7777            'std'     => 'no', // WooCommerce < 2.0
    7878            'default' => 'no', // WooCommerce >= 2.0
    7979            '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' ),
    8181        );
    8282       
  • force-default-variant-for-woocommerce/trunk/includes/variations.php

    r2198872 r2264622  
    33    add_filter( 'woocommerce_product_get_default_attributes', 'hpy_fdv_default_attribute', 10, 1 );
    44    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 );
    56} else {
    67    add_filter( 'woocommerce_dropdown_variation_attribute_options_args', 'hpy_fdv_attribute_args', 10, 1 );
     
    5455
    5556/**
     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 */
     63function hpy_fdv_attribute_args_v2( $args = array() ) {
     64   
     65    $args[ 'show_option_none' ] = false;
     66   
     67    return $args;
     68   
     69}
     70
     71/**
    5672 * Remove the Choose an Option HTML.
    5773 *
     
    6682    return $html;
    6783  }
     84 
     85  return $html;
    6886
    6987    $show_option_none_text = $args['show_option_none'] ? $args['show_option_none'] : __( 'Choose an option', 'woocommerce' );
     
    95113    $sortby = apply_filters( 'hpy_fdv_custom_sortby', !empty( get_option( 'hpy_variant_sort' ) ) ? get_option( 'hpy_variant_sort' ) : 'id' );
    96114    $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' );
    97116   
    98117    if ( $respect == 'yes' && !empty( $defaults ) ) {
     
    116135        $stock_qty = $_child->get_stock_quantity();
    117136        $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       
    119144        if ( $_child->get_status() == 'publish' ) {
    120145            $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  
    44Requires at least: 4.2
    55Tested up to: 5.3
    6 Stable tag: 1.5
     6Stable tag: 1.5.1
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3131
    3232== 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
    3338= 1.5 =
    3439* NEW - Added in a Secondary sort function. If products have the same price you can sort them again by Stock, Sales, ID or Position
     
    3641* UPDATE - Tested up to WordPress 5.3
    3742* UPDATE - Tested up to WooCommerce 3.8
     43
    3844= 1.4.3 =
    3945* NEW - Select Option will now be removed from all product dropdown by default.
     
    4248* FIX - Default selected option field being blank on page load due to missing JS classes.
    4349* UPDATE - Now works with WordPress 5.2 and above.
     50
    4451= 1.4.2 =
    4552* NEW - Adding in the ability to sort by Variant Position
  • force-default-variant-for-woocommerce/trunk/woo-force-default-variant.php

    r2198872 r2264622  
    66Author: HappyKite
    77Author URI: http://www.happykite.co.uk/
    8 Version: 1.5
     8Text Domain: force-default-variant-for-woocommerce
     9Version: 1.5.1
     10WC requires at least: 2.4
     11WC tested up to: 4.0.1
    912*/
    1013
Note: See TracChangeset for help on using the changeset viewer.