Sauter la navigation

[Résolu] Changing the Woocommerce add to cart button colour within a view

Ce fil est résolu. Voici une description du problème et la solution proposée.

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 Il y a 3 années et 9 mois. 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.

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)

Ce sujet contient 2 réponses, a 2 voix.

Dernière mise à jour par barryG-4 Il y a 3 années et 9 mois.

Assisté par: Shane.

Auteur
Publications
#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'>Add</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'>lien caché" class="button product_type_simple">Dates</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:

lien caché

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

lien caché

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? lien caché

#2022415

Shane
Supporter

Les langues: Anglais (English )

Fuseau horaire: 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.