Home Forums WoodMart support forum Add To cart stop working after adding a code to function.php

Add To cart stop working after adding a code to function.php

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #456262

    digital-2058
    Participant

    Hello xtemos support team, I’m using woodmart theme ( Child version) everything is working well until I add this code to function.php :

    add_action( ‘woocommerce_cart_calculate_fees’, ‘add_cash_on_delivery_fee’ );

    function add_cash_on_delivery_fee() {

    $chosen_methods = WC()->session->get( ‘chosen_shipping_methods’ );

    $extra_fee = 10; // Set the extra fee amount here

    // Check if free shipping or Aramex is chosen and add the extra fee
    if ( in_array( ‘free_shipping’, $chosen_methods ) || in_array( ‘wf_aramex’, $chosen_methods ) ) {

    WC()->cart->add_fee( ‘Cash on Delivery Extra Fees’, $extra_fee, true, ‘standard’ );

    }
    }

    This code get the shipping methods and check if the chosen shipping method is free_shipping or aramex so it will add extra fees to the order.

    when I add this code I see that Add to cart button when I clicked on it it’s keep loading and not adding the product to the cart, can you please resolve this for me I purchase the theme and I have a working license code

    #456317

    Hello,

    Thank you very much for choosing our theme and for contacting us.

    Our support covers guidance around the theme and fixing bugs if any, at the same time, our support does not cover investigating and/or fixing third parties code.

    If there are any problems on the site with the code you show, it means the code is not correct. Please advise what your purpose is, perhaps we will offer you a solution without customization.

    Best Regards

    #456408

    digital-2058
    Participant

    Hello dear, Thanks for your reply

    When customer go to checkout and fill his info he will choose between free shipping and Aramex Shipping as shipping methods, and cash on delivery or payment online as payment methods. if customer choose one of these 2 shipping methods and choose cash on delivery payment an extra fees will be added to the order total, the fees value is equal to = 10.

    Can you help me achieve that ?

    #456499

    Hello,

    Please make the full backup of your site and check the issue on the Storefront theme to detect if our theme causes the problem. Storefront is a free theme developed by WooСommerce.

    Best Regards

    #456611

    digital-2058
    Participant

    I tried also the same thing is happening dear

    #456882

    Hello,

    If you see the same on the Storefront, it means this functionality works this way by default.

    WoodMart theme does not influence Woocommerce default functionality. You can try to find a plugin to achieve your purpose. We have not tested any to recommend.

    If you have any questions please feel free to contact us.

    Best Regards

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