- This topic has 19 replies, 2 voices, and was last updated 5 years, 5 months ago by
Elvin.
-
AuthorPosts
-
November 17, 2020 at 12:10 pm #1535222
Heinrich
hi team,
there are few tasks for me regarding “add to cart” button:
– how to get the quantity selector and the add to cart button in one line?
– how to replace the text with an svg-icon. but only in archive and category pages?
– how to add a svg icon right to the add to cart button text on the single product page?
– how to inject the quantity selector into woo blocks. on archive and categorie it works finetks al lot in advance
November 17, 2020 at 2:52 pm #1535387Elvin
StaffCustomer SupportHi,
– how to get the quantity selector and the add to cart button in one line?
We can achieve this by adding CSS:
form.cart { display: flex; align-items: center; } form.cart button.button.alt { margin-top: 0px !important; margin-left: 10px !important; padding: 0; flex-grow: 1; height: 30px !important; } .woocommerce .quantity a.minus, .woocommerce .quantity a.plus, .woocommerce .quantity input.qty { height: 30px !important; min-height: 30px !important; width: 30px !important; }how to replace the text with an svg-icon. but only in archive and category pages?
Can you specify with ones to replace?
– how to add a svg icon right to the add to cart button text on the single product page?
Add this CSS:
body.single-product button.single_add_to_cart_button.button.alt:after { content: ""; background: url(your svg url here); }– how to inject the quantity selector into woo blocks. on archive and categorie it works fine
Woo blocks are added by WooCommerce which is a third party plugin outside of GeneratePress’ scope.
You’ll need a plugin that extends its functionality to add quantity selectors or ask the plugin developer on how to extend its functionality.
Note: As these are mostly WooCommerce issues, it may be best to ask their support for recommendations on most of these things.
November 17, 2020 at 3:30 pm #1535402Heinrich
hi elvin,
topic one is working fine with your code
topic four, i understand and will aks theretopic two, i mean to complete replace the add to cart button text with an icon (only on product-archive and product category pages)
topic three: the code is not working…?
November 17, 2020 at 4:03 pm #1535425Elvin
StaffCustomer Supporttopic two, i mean to complete replace the add to cart button text with an icon (only on product-archive and product category pages)
As per WooCommerce’s official docs, they’re recommending this plugin:
https://wordpress.org/plugins/wc-custom-add-to-cart-labels/Documentation found here.
https://docs.woocommerce.com/document/change-add-to-cart-button-text/Alternatively, you can use PHP snippets to change it:
// 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' ); }You can change the
return __( 'Buy Now', 'woocommerce' );values to your icon mark up.topic three: the code is not working…?
Ah right. That was just a gist. My bad.
This one should work fine:
body.single-product button.single_add_to_cart_button.button.alt:after { content: ""; display: inline-block; background: url(http://haaslm.temp513.kinsta.cloud/wp-content/uploads/tragetasche.png) no-repeat top right; background-size: contain; width: 20px; height: 16px; }November 17, 2020 at 4:31 pm #1535438Heinrich
hi elvin, tks, is working fine. which class i have to adress when i want the same in add to cart button in archive? instead of:
body.single-product button.single_add_to_cart_button.button.alt:after
tks in advance.
November 17, 2020 at 4:40 pm #1535441Elvin
StaffCustomer SupportTo clarify: did you mean the “shoppen” button?
If so, you can use this CSS selector:
body.tax-product_cat form.cart button.button.alt:afterBut you may have to play around with the sizing of the buttons as it will probably look cramped.
November 18, 2020 at 12:16 am #1535644Heinrich
hi elvin,
yes its the "shoppen" button in shop loop. i tried your selector but didnt work.
wondering how and where you have grabbed this one. which tool are you using?
can’t find it with inspector and css inspector?November 18, 2020 at 11:19 am #1536626Elvin
StaffCustomer Supportwondering how and where you have grabbed this one. which tool are you using?
can’t find it with inspector and css inspector?We simply check the webpage by viewing its page source or using Google Chrome’s developer tools by pressing
CTRL + SHIFT + Iwhich is basically the same as right-clicking on the page and pressing “Inspect”.yes its the “shoppen” button in shop loop. i tried your selector but didnt work.
Try this selector instead.
body.archive form.cart button.button.alt:afterNovember 18, 2020 at 11:42 am #1536650Heinrich
hello elvin,
tks, this selector is working. one more thing.
in product single (bottom) in related products, the quantity selector and the add to cart button are not aligned. following code is in place:/* formats add to cart and quantity in one line */
form.cart {
display: flex;
align-items: center;
}form.cart button.button.alt {
margin-top: 0px !important;
margin-left: 10px !important;
padding: 0;
flex-grow: 1;
height: 40px !important;
}.woocommerce .quantity a.minus, .woocommerce .quantity a.plus, .woocommerce .quantity input.qty {
height: 40px !important;
min-height: 40px !important;
width: 40px !important;
}and please also the selector for adding the icon.
tks in advance.
November 18, 2020 at 11:54 am #1536661Elvin
StaffCustomer Supportin product single (bottom) in related products, the quantity selector and the add to cart button are not aligned. following code is in place:
Add this:
div.product form.cart>:not(.quantity):not(.single_add_to_cart_button) { width: auto; }and please also the selector for adding the icon.
Use this:
div.product form.cart>:not(.quantity):not(.single_add_to_cart_button):after { content: ""; display: inline-block; background: url(http://haaslm.temp513.kinsta.cloud/wp-content/uploads/tragetasche.png) no-repeat top right; background-size: contain; width: 20px; height: 16px; }November 18, 2020 at 12:13 pm #1536679Heinrich
image is in the button, but the alignment didn`t work
November 18, 2020 at 12:19 pm #1536687Elvin
StaffCustomer Supportimage is in the button, but the alignment didn`t work</blockquote>
Let’s try using
!important;Try this:
div.product form.cart>:not(.quantity):not(.single_add_to_cart_button) { width: auto !important; }November 18, 2020 at 1:52 pm #1536759Heinrich
next thing is working 🙂 tks.
missing is the alignment in related products in mobile.
November 18, 2020 at 2:31 pm #1536798Elvin
StaffCustomer Support“in die Einkaufstasche is pretty long. Consider resizing its font on mobile so it can fit within the same row.
/* Change add to cart font size on mobile */ @media (max-width:768px){ body.single-product button.single_add_to_cart_button.button.alt { font-size: 12px !important; } }November 18, 2020 at 3:13 pm #1536849Heinrich
perfekt elvin..rockstar 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.