Viewing 15 replies - 1 through 15 (of 31 total)
  • Plugin Support Antonio La Rocca

    (@therock130)

    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 list

    Anyway, please make sure to test this solution on a staging environment before going live

    Thread Starter facundomanzi

    (@facundomanzi)

    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
    Plugin Support Antonio La Rocca

    (@therock130)

    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 );
    Thread Starter facundomanzi

    (@facundomanzi)

    Hi Antonio, now it seems that my site no longer works.
    please help

    Parse 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.

    Plugin Support Antonio La Rocca

    (@therock130)

    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 problem

    My 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 again

    Thread Starter facundomanzi

    (@facundomanzi)

    Thank 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.
    Plugin Support Antonio La Rocca

    (@therock130)

    @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 using wc_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 ??

    Thread Starter facundomanzi

    (@facundomanzi)

    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?

    Plugin Support Antonio La Rocca

    (@therock130)

    Hi @facundomanzi

    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

    Thread Starter facundomanzi

    (@facundomanzi)

    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!!!!

    Thread Starter facundomanzi

    (@facundomanzi)

    -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 it

    I 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”

    Plugin Support Antonio La Rocca

    (@therock130)

    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;
    } );
    Thread Starter facundomanzi

    (@facundomanzi)

    wooow !!!! you are amazing !!!
    I have no words to thank for so much help!
    thank you very very much

    In 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!!!

Viewing 15 replies - 1 through 15 (of 31 total)
  • The topic ‘Total de Wishlist por usuario’ is closed to new replies.