最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugins - Woocommerce Minimum Price for a Composite Product to add in cart

programmeradmin4浏览0评论

I'm making a composite product in Woocommerce, where users can select which products they can choose (like a customized box). I just want that the minimum price to order this composite product should be Say "x". How do i enable that?

I have a code but that will check the overall cart value. How do i do it for this one individual product

add_action( 'woocommerce_checkout_process', 'wc_minimum_order_amount' );
add_action( 'woocommerce_before_cart' , 'wc_minimum_order_amount' );

function wc_minimum_order_amount() {
// Set this variable to specify a minimum order value
$minimum = 50;

if ( WC()->cart->total < $minimum ) {

    if( is_cart() ) {

        wc_print_notice( 
            sprintf( 'You must have an order with a minimum of %s to place your order, your current order total is %s.' , 
                wc_price( $minimum ), 
                wc_price( WC()->cart->total )
            ), 'error' 
        );

    } else {

        wc_add_notice( 
            sprintf( 'You must have an order with a minimum of %s to place your order, your current order total is %s.' , 
                wc_price( $minimum ), 
                wc_price( WC()->cart->total )
            ), 'error' 
        );

    }
}

}
发布评论

评论列表(0)

  1. 暂无评论