Total de Wishlist por usuario
-
Buenas tardes, ayer me puse en contacto con ustedes por medio del canal de Youtube consultando si se puede poner un subtotal en la wishlist. Me respondieron que si se podia y me pasaron este instructivo. https://support.yithemes.com/hc/en-us/articles/115000170153-Wishlist-How-to-display-for-user-the-total-price-of-all-product-in-list.
Tengo la cuenta gratis, me comentaron que no había ningún problema y que se podía hacer. Pero no se como, por eso acudo a ustedes para ver si me pueden ayudar.
Quedo a la espera des sus comentarios
Muchas gracias
Saludos
Facundo
-
Hi Facundo
an easier way to proceed would be the following: copy this snippet of code
add_action( 'yith_wcwl_wishlist_after_wishlist_content', function( $args ) { /** * @var $wishlist YITH_WCWL_Wishlist */ $wishlist = isset( $args['wishlist'] ) ? $args['wishlist'] : false; if ( ! $wishlist ) { return; } $total = 0; if ( $wishlist->has_items() ) { foreach ( $wishlist->get_items() as $item ) { $total += $item->get_product_price(); } } if ( $total ) { echo '<p><b>Total:</b> ' . wc_price( $total ) . '</p>'; } }, 5 );
and paste it at the end of functions.php file of your theme or child theme
This should add a new line after your wishlist, with total of items in listAnyway, please make sure to test this solution on a staging environment before going live
Hi Antonio!
Thank you very much for your quick reply, Unfortunately I don't know where to add it. I use a plugin called "Snippets" I added it like this but it gave me an error on the site. What I can do?
I look forward to your comments Regards Facundo
Hi again Facundo
You can surely use Snippets plugin, if it allows you to add arbitrary script of PHP code to your installation (even if it wouldn’t be my choice)
Regarding the error, if you could paste the returned error code, it would help me debug
It could possibly be something related to PHP version, in which case I’d suggest you to try with this slightly different snippet of code:if ( ! function_exists( 'yith_wcwl_items_total' ) ) { function yith_wcwl_items_total( $args ) { /** * @var $wishlist YITH_WCWL_Wishlist */ $wishlist = isset( $args['wishlist'] ) ? $args['wishlist'] : false; if ( ! $wishlist || ! $wishlist instanceof YITH_WCWL_Wishlist ) { return; } $total = 0; if ( $wishlist->has_items() ) { foreach ( $wishlist->get_items() as $item ) { $total += $item->get_product_price(); } } if ( $total ) { echo '<p><b>Total:</b> ' . wc_price( $total ) . '</p>'; } } } add_action( 'yith_wcwl_wishlist_after_wishlist_content', 'yith_wcwl_items_total', 5, 1 );
Hi Antonio, now it seems that my site no longer works.
please helpParse error: syntax error, unexpected ‘&’ in /home/customer/www/somoswarm.com/public_html/wp-content/plugins/code-snippets/php/snippet-ops.php(469) : eval()’d code on line 1
There has been a critical error on this website. Please check your site admin email inbox for instructions.Hi there
I’m sorry, but I don’t know where the problem could come from
As you can see there is no&
symbol in my snippet, so I don’t think it may be the source of the problemMy suggestion in order to revert your site functionality is to deactivate your snippet plugin, but accessing your server using FTP and renaming plugin folder under wp-content/plugins/ (you can simply add .bak at the end of folder name)
This will disable plugin and allow site load againThank you very much !!!! You are the best!!! I changed my PHP and the first code works amazing! I leave you the best recommendation hahaha! I’m so happy!
One more question! Is there a way to change the symbol from $ to CO2 / year?
Hi Antonio !
Thank you for the tip, it was exactly what I was looking for and it’s working ! Nevertheless, the total doesn’t include the quantity of pieces added in the wishlist.
How can I fix that ?
-
This reply was modified 3 years, 10 months ago by
gwenmrlt.
@facundomanzi I’m glad to hear that my code helped ??
Regarding your question, do you want to change any price label in your list or just the total? We’re usingwc_price
to print any price, and of course it refers to price format configured in WooCommerce
If you want to change that, you’ll need to manually format your prices; I could easly change my snippet of code to use a different format, but changing wihslist items requires you to override a template, and it could be a little harder@gwenmrlt In this version of the plugin, by default any item will be added with quantity 1 and there is no way to change that
If you’re using a commercial copy of our plugin, feel free to issue a support ticket to our dedicated help desk: we will be happy to help you with your task ??Thank you for your fast answer Antonio. I’m opening a support ticket then ??
Thank you very much Antonio, So changing the price symbol “$” for “Kg de CO2 /a?o” in the whole site is very complicated but if it can be done in the total of the wish list?
I need to say in the total: Total: 500 Kg de CO2 / a?o
Can this be done?here’s an updated version of the script that I originally shared with with you
add_action( 'yith_wcwl_wishlist_after_wishlist_content', function( $args ) { /** * @var $wishlist YITH_WCWL_Wishlist */ $wishlist = isset( $args['wishlist'] ) ? $args['wishlist'] : false; if ( ! $wishlist ) { return; } $total = 0; if ( $wishlist->has_items() ) { foreach ( $wishlist->get_items() as $item ) { $total += $item->get_product_price(); } } if ( $total ) { echo '<p><b>Total:</b> ' . number_format( $total, wc_get_price_decimals(), wc_get_price_decimal_separator(), wc_get_price_thousand_separator() ) . ' Kg de CO2 /a?o</p>'; } }, 5 );
This should apply required changes
Wow !!! you’re great!!! how I wish I could learn to do this! I would love to learn!
-And with the prices on the wish list it can also be done?
-Change Product name to: “Actions for the Climate”
-and the Unit Price per “Kg of CO2 / year”
I hope I don’t bother you with my questions but it’s great to be able to do this
Thanks!!!!-And with the prices on the wish list it can also be done?==> I’ve already done it
-Change Product name to: “Actions for the Climate”
-and the Unit Price per “Kg of CO2 / year” ==> I’ve already done itI have a problem when I add “After adding the product to the wish list” ==> Show the link “Remove from the list”. I would like to change “Remove from list” to “Eliminar Accion” and also appear “or View? “I would like to remove this. How can In do this?
-On the wish list Change Product name to: “Actions for the Climate”Hi again
let me try answer your question
-And with the prices on the wish list it can also be done?
Try with this snippet
add_filter( 'yith_wcwl_item_formatted_price', function ( $formatted_price, $base_price ) { return number_format( $base_price, wc_get_price_decimals(), wc_get_price_decimal_separator(), wc_get_price_thousand_separator() ) . ' Kg de CO2 /a?o'; }, 10, 2 );
-Change Product name to: “Actions for the Climate”
Try with this snippet
add_filter( 'yith_wcwl_wishlist_view_name_heading', function() { return 'Actions for the Climate'; } );
I would like to change “Remove from list” to “Eliminar Accion”
Try with this snippet
add_filter( 'yith_wcwl_remove_from_wishlist_label', function() { return 'Eliminar Accion'; } );
nd also appear “or View? “I would like to remove this. How can In do this?
Try with this snippet
add_filter( 'yith_wcwl_add_to_wishlist_params', function( $args ) { $args['show_view'] = false; return $args; } );
wooow !!!! you are amazing !!!
I have no words to thank for so much help!
thank you very very muchIn each product, in the template that I put together in the Divi Theme Builder there is the option to "Add to wish list". On this product page after adding the product to my wish list appears "remove from wish list". This text is the one that I want to modify "remove from wish list" to "Remove Action". The same thing happens to me with the word Category that I want to put it in Spanish I would like to learn how is the logic to make these combinations in text, could you give me some tip or instructions that I can see
Thankssss a lot!!!
-
This reply was modified 3 years, 10 months ago by
- The topic ‘Total de Wishlist por usuario’ is closed to new replies.