Compatibility fix for WooCommerce Color or Image Variation plugin

The WooCommerce Color or Image Variation plugin is a popular WooCommerce extension found on CodeCanyon.

It lets you create colour or image selectors for each of your variations with relative ease.

We recently debugged and fixed a compatibility issue with this plugin where the minimum order quantity would not pre-populate in the quantity box.

The fix is to install this small snippet of code into the functions.php of your theme:

function wwppColourImageMinVarFix($variationData) {
    global $current_user;

    if (isset($current_user) && class_exists('WWP_Wholesale_Roles')) {
        $wwp_wholesale_roles = WWP_Wholesale_Roles::getInstance();
        $wwp_wholesale_role = $wwp_wholesale_roles->getUserWholesaleRole();
        if (!empty($wwp_wholesale_role)) {

            // Get min qty for this variation
            $product_id = $variationData['variation_id'];
            $wwpp_wholesale_prices = WWPP_Wholesale_Prices::getInstance();
            $wholesalePrice = $wwpp_wholesale_prices->getProductWholesalePrice( $product_id , $wwp_wholesale_role );
            $wholesalePrice = apply_filters( 'wwp_filter_wholesale_price_shop' , $wholesalePrice , $product_id , $wwp_wholesale_role );

            $minimumOrder = get_post_meta( $product_id , $wwp_wholesale_role[0] . "_wholesale_minimum_order_quantity" , true );

            if ( $minimumOrder && $wholesalePrice )
                $variationData['min_qty'] = $minimumOrder;

        }
    }

    return $variationData;
}

add_filter('woocommerce_available_variation', 'wwppColourImageMinVarFix', 10, 1);

Solve The Big Three Problems With Wholesaling In WooCommerce

Add wholesale pricing to products   Streamline your ordering   Register & manage wholesale customer

Explore The Plugin Suite  

[data-image-id='gourmet_bg']
[data-image-id='gourmet_bg']
[data-image-id='gourmet_bg']
[data-image-id='gourmet_bg']
[data-image-id='gourmet_bg']
[data-image-id='gourmet_bg']
[data-image-id='gourmet']
[data-image-id='gourmet']
[data-image-id='gourmet']
[data-image-id='gourmet']
[data-image-id='gourmet']
[data-image-id='gourmet']
[data-image-id='gourmet']
[data-image-id='gourmet']
[data-image-id='gourmet']
[data-image-id='gourmet']