@elliecoxy,
can you share me admin screenshot of this specific product that you’ve shared.
I have emailed you a screenshot, thanks
I’ve found a fix for this. The follow code is properly styled, fully compatible and works correctly, i.e. it adds the correct minimum quantity to the cart for simple products and links variable product buttons to the respective product page:
add_filter( 'woocommerce_loop_add_to_cart_link','_wcmmax_add2cart' );
function _wcmmax_add2cart( $link ) {
global $product;
$product_id = $product->get_id();
$product_sku = $product->get_sku();
$product_type = $product->get_type();
$qtylink = '';
$mmaxEnable = get_post_meta( $product_id, '_wc_mmax_prd_opt_enable', true );
$minQty = get_post_meta( $product_id, '_wc_mmax_min', true );
if ( $product_type != 'simple' || $mmaxEnable != 1 ){
return $link;
}
$qtylink = '&quantity='.$minQty;
$ajax_cart_en = 'yes' === get_option( 'woocommerce_enable_ajax_add_to_cart' );
if ( $ajax_cart_en && $mmaxEnable == 0 ) {
$ajax_class = 'ajax_add_to_cart';
}
$link = sprintf( '<a href="%s" rel="nofollow" data-product_id="%s" data-product_sku="%s" data-quantity="%s" class="button %s product_type_%s %s">%s</a>',
esc_url( $product->add_to_cart_url().$qtylink ),
esc_attr( $product_id ),
esc_attr( $product->get_sku() ),
esc_attr( isset( $minQty ) ? $minQty : 1 ),
$product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '',
esc_attr( $product->product_type ),
esc_attr( $ajax_class ),
esc_html( $product->add_to_cart_text() )
);
return $link;
}
@wpashokg please udpate the plugin.
@elliecoxy, @galbaras, update to the latest version of plugin and check now.
Thank you both, it is now working again
Hi there,
I am using your Woocommerce Minimum and Maximum Quantity on my website as well as the WP Clever frequently bought together premium plugin. I am not sure if they are not compatible or what the problem is, but as soon as I activate your plugin the qty’s will not stay on 0 they start on 1 and you have to either click the + or – to get it to add the amount to the bottom and to the cart? I have set the default qty in the bought together products to 0. When I deactivate your plugin the default qty is 0, when I activate your plugin it becomes a 1.
Do you perhaps know why it’s doing that and is there a way to fix it?
Here is the link to the product page: https://www.adroitscada.com/catalog/shop/adroit-ignite/adroit-agent-server-ignite-8-agents/
Kind Regards,
Sam
This thread has been marked as “resolved”. You should start a new thread with a better title.