Skip Navigation

[Gelöst] Changing the Woocommerce add to cart button colour within a view

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem:

The issue here is that the user wanted to change their Woocommerce Add to Cart button color.

Solution:
This can be done by using the CSS below.
.woocommerce form.cart button.button {
background-color: #000;
}

To change the hover color you will need the following
.woocommerce form.cart button.button:hover {
background-color: #fe5252;
}

This support ticket is created vor 3 Jahre. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 2 Antworten, has 2 Stimmen.

Last updated by barryG-4 vor 3 Jahre.

Assisted by: Shane.

Author
Artikel
#2022201

Tell us what you are trying to do?
I have created a set of views for displaying Woocommerce products with a query set to show only products with a custom post type relationship. I’m very happy with how things look but I’ve just had to add a WooCommerce Rental plug in and when products are set to ‘Rental Only’ within WooCommerce, the code for the add to cart button changes. I used the following toolset field for the button: [wpv-woo-buy-or-select add_to_cart_text="Add”]. I used view page source to see the class of the original button (when all products were not rentals) and it is as follows:

<span class='bgpcCart'><a href="?add-to-cart=11025" data-quantity="1" class="button product_type_simple add_to_cart_button ajax_add_to_cart " data-product_id="11025" data-product_sku="" aria-label="Add “Canon EOS-R5 sales” to your cart" rel="nofollow">Add</a></span>

To make the button background a black colour I used the following in my theme’s Custom CSS section:

.button.product_type_simple.add_to_cart_button.ajax_add_to_cart{background-color:black;}

This doesn’t work with the rental only products though. They still show as the default blue colour.

This is the add to cart button code when products are set to rental only:
<span class='bgpcCart'><a href="hidden link" class="button product_type_simple">Dates</a></span> (I changed the button text from Add to Dates but nothing else).

Therefore I tried adding this to css within the view and alternatively in the theme’s Custom CSS section but nothing changes:
.button.product_type_simple{background-color:black;}

Can you help. Is there something I can write within the view code itself to force the button to change colour or is there anything else you can think of?

The non rental page that shows the button colour correctly is:

hidden link

And the incorrect blue button for rental only products is here (currently set to home page):

hidden link

Many thanks,
Barry.

Is there any documentation that you are following? No

Is there a similar example that we can see? No

What is the link to your site? hidden link

#2022415

Shane
Supporter

Languages: Englisch (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Barry,

Thank you for getting in touch.

Try using this css below.

.bgpcCart a{
background-color: black !important;
}

Please let me know if this forces the button to change its background color to black.

Thanks,
Shane

#2022417

Hi Shane,

Thank you so much for doing this so quickly. I'm annoyed I had to bother you with it as now I can see the answer I think I could have tried it myself but I wouldn't have known to add the !important; bit.

Many thanks,
Barry.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.