Woocommerce cart deposit

寵の児 提交于 2020-01-16 04:01:07

问题


I have this code for Woocommerce orders, basically a deposit fee per order. But the customer should only be able to pay this fee and the rest later. There are heaps of solutions for product based deposit fees, but not per cart. Any ideas, thoughts on how to force this on checkout and the rest later?

add_action( 'woocommerce_cart_calculate_fees', 'booking_fee' );
function booking_fee() {
    global $woocommerce;

    if ( is_admin() && ! defined( 'DOING_AJAX' ) )
        return;

 $bookingfee_array = array( '2434' );

    $fixed = 40.00;

    foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $values ) {

        if( in_array( $values['product_id'], $bookingfee_array ) ) {
            $surcharge = $fixed;
            $woocommerce->cart->add_fee( 'Broneeringutasu', $surcharge, true, '' );
        }

    }

}

来源:https://stackoverflow.com/questions/32777765/woocommerce-cart-deposit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!