Home › Forums › WoodMart support forum › change behaveor of the add to cart buttom
change behaveor of the add to cart buttom
- This topic has 5 replies, 2 voices, and was last updated 8 months ago by Aizaz Imtiaz Awan.
-
AuthorPosts
-
April 15, 2024 at 5:06 pm #557387
av_admin_1984ParticipantHi
Is it possible to change behavor of the “add to cart” buttom?
I dont mean to change the text, I want this buttom open the product not added to cartApril 16, 2024 at 10:40 am #557570
Aizaz Imtiaz AwanKeymasterHello,
Define the code below in the functions.php file in your child theme.
/* Remove add to cart button */ add_action('woocommerce_before_shop_loop_item','remove_loop_add_to_cart_button'); function remove_loop_add_to_cart_button(){ global $product; // Current product remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 ); } /* Add see details button to replace add to cart button*/ add_action('woocommerce_after_shop_loop_item','replace_add_to_cart_with_view_product'); function replace_add_to_cart_with_view_product() { global $product; $link = get_permalink(); echo '<a class="button" href="' . esc_attr($link) . '">See Details</a>'; }
Best Regards.
April 16, 2024 at 11:40 am #557617
av_admin_1984ParticipantExcellent
Thank you for thisI found this code too from stackoveflow
what are the differences between them?
// First, remove AJAX Add to Cart Button remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 ); // Second, add View Product Button add_action( 'woocommerce_after_shop_loop_item', 'shop_view_product_button', 10); function shop_view_product_button() { global $product; $link = $product->get_permalink(); echo '<a href="' . $link . '" class="button addtocartbutton">نمایش کالا</a>'; }
April 16, 2024 at 4:26 pm #557730
Aizaz Imtiaz AwanKeymasterHello,
The code you found on Stack Overflow achieves the same result as the code I provided. Both replace it with a “View Product” button. The difference lies in the way they’re implemented.
Best Regards.
April 17, 2024 at 1:22 pm #557982
av_admin_1984ParticipantI will use your code in this case
close this topic please
Thanks
April 17, 2024 at 3:39 pm #558051
Aizaz Imtiaz AwanKeymasterMost Welcome!!!.
I’m so happy to hear you are pleased with the Theme and Support. XTEMOS strives to deliver the best customer experience, and it makes our day to hear we have accomplished that.
We count ourselves lucky to have you as a customer. You can always reach us at any time. We are always here to help you.
Thanks for contacting us.
Have a great day.Topic Closed.
Best Regards. -
AuthorPosts
- You must be logged in to create new topics. Login / Register