Answers for "wp add to cart button on product detail page"

PHP
3

How to change add to cart button in wordpress

// To change add to cart text on single product page
add_filter( 'woocommerce_product_single_add_to_cart_text', 'woocommerce_custom_single_add_to_cart_text' ); 
function woocommerce_custom_single_add_to_cart_text() {
    return __( 'Buy Now', 'woocommerce' ); 
}

// To change add to cart text on product archives(Collection) page
add_filter( 'woocommerce_product_add_to_cart_text', 'woocommerce_custom_product_add_to_cart_text' );  
function woocommerce_custom_product_add_to_cart_text() {
    return __( 'Buy Now', 'woocommerce' );
}
Posted by: Guest on May-02-2020
0

wp wc add to cart button with product id

$product_object = wc_get_product( $product_id );
echo '<a href="' . esc_url( $product_object->add_to_cart_url() ) . '" class="buy-now button">' . esc_html__( 'Buy Now', 'text-domain' ) . '</a>';
Posted by: Guest on June-23-2021

Code answers related to "wp add to cart button on product detail page"

Browse Popular Code Answers by Language