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
- This topic has 5 replies, 2 voices, and was last updated 1 year, 8 months ago by Elise Noromit.
-
AuthorPosts
-
April 1, 2023 at 3:40 pm #456262
digital-2058ParticipantHello 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
April 2, 2023 at 2:04 am #456317
Elise NoromitMemberHello,
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
April 2, 2023 at 1:50 pm #456408
digital-2058ParticipantHello 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 ?
April 3, 2023 at 5:13 am #456499
Elise NoromitMemberHello,
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
April 3, 2023 at 12:01 pm #456611
digital-2058ParticipantI tried also the same thing is happening dear
April 4, 2023 at 2:20 am #456882
Elise NoromitMemberHello,
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
-
AuthorPosts
- You must be logged in to create new topics. Login / Register