• Resolved bassbossbass

    (@bassbossbass)


    I’m interested to know if the Custom Add To Cart button has any possible option for displaying the changes on a per page/product basis instead of only globally.

    The page i have it on that it is proper on is this: https://www.staging3.buybassboss.com/buy/vs21-powered-subwoofer/
    I will be wanting the change on every product page i choose.

    But on all other pages i want to have the normal button unaffected. The first link i gave you shows the button how i do not want it.

    Let me know,
    Thanks,
    Glen Allan
    IS Coordinator
    BASSBOSS

    The page I need help with: [log in to see the link]

Viewing 13 replies - 1 through 13 (of 13 total)
  • Hi Glen,

    Sorry for delay getting back to you. I wasn’t getting updates on support for this plugin for some reason.

    Yes, you can change the button for certain products only, but it would require adding some code to your theme. You need to use the ‘wcatc_replace_text_single_product’ filter. It returns a true or false value – true means “replace the text”, false means “don’t replace”. So for products you want to replace, you can return true, for everything else return false.

    Here’s an example changing the text for just one product called “Subwoofer”:

    
    add_filter( 'wcatc_replace_text_single_product', 'wcatc_replace_cart_text_for_specific_products' );
    
    function wcatc_replace_cart_text_for_specific_products( $replace, $product ) {
    	if ( 'Subwoofer' === $product->get_name() ) {
    		return true;
    	}
    	return false;
    }
    

    Hope that helps…

    • This reply was modified 6 years, 7 months ago by Andy Keith.
    Thread Starter bassbossbass

    (@bassbossbass)

    Hi Andy,

    Hmm… That’s close. However the way the site is set up would make that odd. We use a loop archive plugin that pulls product info and displays it on a page where i want all of the products to have the same normal cart with text and no button, whereas i have individual products in a different format where i don’t want the text and do want the icon. So in this way the same product would show it different ways on multiple pages.

    Ideally it would be like using a CSS page-id kind of deal where the change in display is on a page basis, not the product everywhere. Can a similar thing be done by using a page id?

    Let me know,
    Glen Allan
    IS Coordinator
    BASSBOSS

    Hi Glen,

    The wcatc_replace_text_single_product filter only applies on the single product pages, and not ‘in the loop’ (e.g. on the shop page or in categories). The filter basically runs as part of the woocommerce_product_single_add_to_cart_text filter in WooCommerce. For info, our plugin also provides a wcatc_replace_text_in_loop filter.

    So am I right in thinking that this filter should work for you, as it wouldn’t run on your loop archive pages, but would run on the single products?

    Andy

    Greetings Andy
    I am hoping to change the Cart Button to a Call Us button that either is not a link or is linked to the contact page of a site. Similar to what this site has accomplished using Barn2 Media Product Table Plugin. https://rotorcorp.com/parts/

    Hi,
    You won’t be able to do that with this plugin. It’s just a simple plugin to change the text of the cart button, or add an icon.

    Thread Starter bassbossbass

    (@bassbossbass)

    Andy,

    No, the loop archive pulls the single add to cart info from each page for it’s display. In a sense it hijacks the WooCommerce cart and allows display in many ways all over the site, even on non product pages and posts. Since your mods to the Woo engine are at the most basic level i’d guess it can’t be both things at the same time (which i get).

    I was hoping it would just be an issue of the icon maybe having a different CSS identifier which would allow the hide function to style it either way on a per page basis, but i get if it can’t due to being part of the same item.

    I think i’ll need to find a solution that creates the same call to add the product to the cart but with a trigger i can fully customize. I’ll check the WooCommerce docs and see what the other options are.

    Thanks for answering!

    Glen Allan
    IS Coordinator
    BASSBOSS

    Thread Starter bassbossbass

    (@bassbossbass)

    Oh, maybe i can use CSS. I think i was using a different program to find the selector. I’ll test and let you know.

    Thread Starter bassbossbass

    (@bassbossbass)

    Andy,

    It looks like the cart icon can be shown or removed with CSS, but the text cannot without the whole button also disappearing using the “display: none;” operator. There are a ton of selectors involved, so i’m going to see if any of them only deal with the text and leave everything else. If you happen to know what the specific selector would be that could do this it would pretty much solve the problem and i can add CSS to control the display on the pages i want and don’t.

    If i find it i’ll post here so others can refer to it. Otherwise i’ll await your response.

    Thanks,
    Glen Allan
    IS Coordinator
    BASSBOSS

    Hi Glen,

    I’m not 100% sure what you’re trying to do. If you want to hide the ‘Add to cart’ text, you can do that in our plugin by going to Appearance -> Customize -> WooCommerce -> Add to Cart Buttons, then ticking the ‘Hide Add to Cart Text’ option.

    https://prnt.sc/kmzhou

    Thread Starter bassbossbass

    (@bassbossbass)

    Andy,

    Like stated, i’m interested in hiding and showing the options on a per page basis. Apparently, since your plugin adds the cart icon, it can also be removed via CSS using a page or post ID tag and the selector for the cart icon. However i don’t see a selector for the text that doesn’t also remove the entire cart button using the “display: none;” option.

    I’m looking to be able to chow or hide either element (text or icon) per page (not product, as some products show up on multiple pages). If you are aware of a selector i’m not able to find, i’d appreciate it, otherwise i’ll be trying to find another solution.

    Thanks,
    Glen Allan
    IS Coordinator
    BASSBOSS

    Hi Glen,

    To hide the icon you can use this selector

    
    .wc-add-to-cart-icon .single_add_to_cart_button:before, .wc-add-to-cart-icon .add_to_cart_button.text_replaceable:before {
       content: none;
    }
    
    Thread Starter bassbossbass

    (@bassbossbass)

    Hi Andy,

    Yes, i figured out the icon hiding. I’m also trying to hide just the text while it’s still active on other pages (with the icon showing still). For some pages i just want the icon, for some pages i just want the text. For some pages i may want both displayed, on a per page basis.

    Is there a selector to hide the text that doesn’t also hide the whole cart button?

    Thanks,
    Glen

    Hi,

    No there isn’t a separate selector for just the text unfortunately.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Display the Custom change on some pages only’ is closed to new replies.