I work on site that use External products from Amazon, but want instead pointing users to that external URL, first to add to cart that product. I have this function, that change Default Button text for each product, to Add to cart.

function sv_wc_external_product_button( $button_text, $product ) {

if ( 'external' === $product->get_type() ) {
    // enter the default text for external products
    return $product->button_text ? $product->button_text : 'Add To Cart';
}

return $button_text;
}
add_filter( 'woocommerce_product_single_add_to_cart_text', 
'sv_wc_external_product_button', 10, 2 );

But this function not add product to cart. How to make this function to Add selected product to cart?

Thanks in advance.

Read more here: Override External Product URL to "Add to Cart" product button


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: