In ProgressDiscount for local pickup

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #37347
    pascal
    Participant

    Hello,
    I would like to setup a discount % for customer who choose local pickup.

    Before getting to you, I searched on different forums, plugins, etc.

    I see that this could be done by adding a snippet to function file.
    For example on Woofood, I found this:

    function wpslash_add_discount_for_pickup() {
    global $woocommerce;
    if ( is_admin() && ! defined( ‘DOING_AJAX’ ) )
    return;
    $order_type = WC()->session->get( ‘woofood_order_type’ );

    $percentage = 20;
    $discount_amount = $woocommerce->cart->cart_contents_total * ($percentage/100);
    if($order_type == “pickup”)
    {
    $woocommerce->cart->add_fee( ‘Pickup Discount’, -$discount_amount, true, ” );

    }

    }
    add_action( ‘woocommerce_cart_calculate_fees’,’wpslash_add_discount_for_pickup’ );

    Could you help me with this or tell me if such code is available to include on my website?

    Thanks a lot.

    Kind regards
    Pascal

    #37365
    Alex
    Keymaster

    Hello Pascal,

    With the default WooCommerce “Local pickup” shipping type you can set up negative amount, i.e. -10 , but you can not set percentage.

    Looking at the snippet, seams that it could work.

    You can test it by adding it to a child theme.

    Regards,
    Alex

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in and have valid license to reply to this topic.

License required for the following item
Login and Registration Log in · Register