• Skip to main content
  • Skip to primary sidebar

WordPress, Genesis Framework and Storefront customization tutorials

  • Archive
    • Genesis
    • WooCommerce
    • WordPress
  • Premium
  • Blog
  • About
    • Tools I Use
  • Contact
  • Login
Home » add to cart

add to cart

Change “Add to cart” button text on specific pages in Woo

2020-02-18 by Gabor 1 Comment

// =========================================================================
// CHANGE ADD TO CART BUTTON TEXT ON SPECIFIC PAGES
// =========================================================================
function translate_add_to_cart() {
    global $product;
    if( $product->id == 2028 ){
        return __( 'Add to basket', 'woocommerce' );
    } elseif($product->id == 2027){
        return __( 'Buy now', 'woocommerce' );
        }
    else{
        return __( 'Add to cart', 'woocommerce' );
    }
}
add_filter( 'woocommerce_product_single_add_to_cart_text', 'translate_add_to_cart', 10, 3 );

Filed Under: WooCommerce Tagged With: add to cart, is_product, product id, specific product

Change add to cart button to view product

2018-05-13 by Gabor


/*STEP 1 - REMOVE ADD TO CART BUTTON ON PRODUCT ARCHIVE (SHOP) */

function remove_loop_button(){
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
}
add_action('init','remove_loop_button');

/*STEP 2 -ADD NEW BUTTON THAT LINKS TO PRODUCT PAGE FOR EACH PRODUCT */

add_action('woocommerce_after_shop_loop_item','replace_add_to_cart');
function replace_add_to_cart() {
global $product;
$link = $product->get_permalink();
echo do_shortcode('<a href="'.$link.'" class="button addtocartbutton">Megtekintés</a>');
}

Filed Under: WooCommerce Tagged With: add to cart

Add Tabs after Add to cart button

2018-05-13 by Gabor


//Add Tabs after Add to cart button
add_action( 'woocommerce_single_product_summary', 'wc_custom_show_attributes_outside_tabs', 35 );
function wc_custom_show_attributes_outside_tabs() {
global $product;
$product->list_attributes();
}

Filed Under: WooCommerce Tagged With: add to cart

Primary Sidebar

  • Facebook
  • GitHub
  • Instagram
  • LinkedIn
  • Twitter
  • YouTube
WP Rocket - WordPress Caching Plugin
UpdraftPlus Premium

Disclosure: Some of the links in this site are affiliate links. I will be paid a commission if you use this link to make a purchase.

  • Privacy Policy
  • Flames Design
© 2021 WP Flames - All Right Reserved