• You MUST read the Babiato Rules before making your first post otherwise you may get permanent warning points or a permanent Ban.

    Our resources on Babiato Forum are CLEAN and SAFE. So you can use them for development and testing purposes. If your are on Windows and have an antivirus that alerts you about a possible infection: Know it's a false positive because all scripts are double checked by our experts. We advise you to add Babiato to trusted sites/sources or disable your antivirus momentarily while downloading a resource. "Enjoy your presence on Babiato"

how to change add to cart become a social link

asyifa

Active member
Dec 10, 2018
470
130
43
hello, am i really confused how to change link add to cart in wordpress, i want change this but i dont know, where location this code, my bf say to me, impossible 😣
 
Do you mean the Add To Cart in WooCommerce? If so, it can be done. How are you with coding?

One of my clients needed to change the "Add to Cart" to "View Product". To do this we added the following PHP code at the bottom of the child theme functions.php. If you have no child theme, it goes in the themes functions.php, but you will need to add it again if your theme updates.

Not exactly what you want, but will give you an idea of the coding required.


PHP:
/**
 * @snippet       Remove Add Cart, Add View Product @ WooCommerce Loop
 * @add to child theme functions.php
 */
 
// First, remove 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', 'view_product_button', 10);
 
function view_product_button() {
global $product;
$link = $product->get_permalink();
echo '<a href="' . $link . '" class="button addtocartbutton">View Product</a>';
}
 
AdBlock Detected

We get it, advertisements are annoying!

However in order to keep our huge array of resources free of charge we need to generate income from ads so to use the site you will need to turn off your adblocker.

If you'd like to have an ad free experience you can become a Babiato Lover by donating as little as $5 per month. Click on the Donate menu tab for more info.

I've Disabled AdBlock