Plugin Directory

Changeset 2985019


Ignore:
Timestamp:
10/27/2023 02:45:01 PM (2 years ago)
Author:
HappyKite
Message:

Version 1.8 Released

  • FIX - Issue with multiple attributes fixed
  • NEW - Tested and declared compatibility with WC HPOS
  • UPDATE - Works with WooCommerce 8.2.1
  • UPDATE - Works with WordPress 6.3.2
Location:
force-default-variant-for-woocommerce
Files:
8 added
3 edited

Legend:

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

    r2886515 r2985019  
    7474    if ( ! $product ) {
    7575        return $defaults;
     76    }
     77
     78    if ( is_string( $product ) ) {
     79        $product = wc_get_product( get_queried_object_id() );
     80        if ( empty( $product ) || is_wp_error( $product ) ) {
     81            return $defaults;
     82        }
    7683    }
    7784
     
    146153            $secondary_sort = true;
    147154            $attributes     = hpy_fdv_multidimensional_sort( $attributes, 'price-low' );
     155            $attributes     = hpy_fdv_remove_element_by_value( $attributes, 'price', '0' );
     156
    148157            break;
    149158
     
    151160            $secondary_sort = true;
    152161            $attributes     = hpy_fdv_multidimensional_sort( $attributes, 'price-high' );
     162            $attributes     = hpy_fdv_remove_element_by_value( $attributes, 'price', '0' );
    153163            break;
    154164
     
    237247
    238248    return apply_filters( 'hpy_fdv_attributes_return', $defaults );
     249}
     250
     251function hpy_fdv_remove_element_by_value($array, $key, $value){
     252    foreach ($array as $subKey => $subArray) {
     253        if ($subArray[$key] == $value) {
     254            unset($array[$subKey]);
     255        }
     256    }
     257    return $array;
    239258}
    240259
  • force-default-variant-for-woocommerce/trunk/readme.txt

    r2886515 r2985019  
    33Tags: WooCommerce, Variable product, WooCommerce variant, eCommerce
    44Requires at least: 4.2
    5 Tested up to: 6.1.1
    6 Stable tag: 1.7
     5Tested up to: 6.3.2
     6Stable tag: 1.8
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3131
    3232== Changelog ==
     33= 1.8 - 27th October 2023 =
     34* FIX - Issue with multiple attributes fixed
     35* NEW - Tested and declared compatibility with WC HPOS
     36* UPDATE - Works with WooCommerce 8.2.1
     37* UPDATE - Works with WordPress 6.3.2
     38
    3339= 1.7 - 24th March 2023 =
    3440* NEW - Adds the ability to order variations Alphabetically
  • force-default-variant-for-woocommerce/trunk/woo-force-default-variant.php

    r2886515 r2985019  
    77 * Author URI: http://www.happykite.co.uk/
    88 * Text Domain: force-default-variant-for-woocommerce
    9  * Version: 1.7
     9 * Version: 1.8
    1010 * WC requires at least: 2.4
    11  * WC tested up to: 7.5.1
     11 * WC tested up to: 8.2.1
    1212 */
    1313
     
    5757
    5858}
     59
     60/****************************
     61 * Declare HPOS Compatibility
     62 ****************************/
     63
     64add_action( 'before_woocommerce_init', function() {
     65    if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
     66        \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
     67    }
     68} );
    5969
    6070
Note: See TracChangeset for help on using the changeset viewer.