php - Changing WooCommerce buy button link? -
so have set woocommerce child theme , organized website dummy data.
i can't find way change link "add cart" external link. want each time clicks on "add cart" button user taken external link example.com
how go this?
p.s: i'm not worried of security aspects since site won't used real money transactions.
not going ask idea behind question, using filter sure need:
<?php add_filter( 'woocommerce_loop_add_to_cart_link', 'change_add_product_link' ); function change_add_product_link( $link ) { global $product; $product_id = $product->id; $product_sku = $product->get_sku(); $link = '<a href="//www.yourtargeturl.com?id='.$product_id.'" rel="nofollow" data-product_id="'.$product_id.'" data-product_sku="'.$product_sku.'" data-quantity="1" class="button add_to_cart_button product_type_variable">'.sfws_woocommerce_product_add_to_cart_text().'</a>'; return $link; } ?>
Comments
Post a Comment