Tagged: ,

Viewing 30 posts - 1 through 30 (of 33 total)
  • Author
    Posts
  • #505325

    Hey Guys,

    I just need to display single price and total price in the cart:

    so for 1 piece

    € 15,- | € 15,-

    and for 2 piece

    € 15,- | € 30,-

    Is there a way to fix it?

    Thanks Stephan

    #505421

    Hey handelsmann!

    Can you please post a screenshot and show the changes you would like to make so we can make sure that we are on the same page?
    You can upload your screenshots on imgur.com or Dropbox public folder and post the links here.

    Cheers!
    Yigit

    #505769

    Hi Yigit,

    hope that does work too. What I want to have is either
    that single or einzeln.jpg and if you change numbers of pieces to two than doppelt.jpg

    Regards
    Stephan

    #506229

    Hey!

    I’m sorry but I don’t think that’s possible without major customization in the plugin. You can only see the total of the product price if you visit the actual cart page, after you add the product item in the cart. Please contact the woocommerce support, maybe they can modify the quantity button to update the price automatically.

    Cheers!
    Ismael

    #506283

    Hey Ismael,

    mmmmh, I think this is a quite normal standard to know what is in the cart and if you raise the numbers it should be obvious for the buyer. Major customization`? Really? – you have the number of a single price and just have to multiply it whith the chosen pieces – think it should be easy for someone who is familiar with the theme to extract that two variables (single price/numbers) to multiply. Don’t you think so? Mmmmh.

    Is it maybe just a plugin? Saw something about Dynamic Pricing. Do you know if that works?

    Best Stephan

    #506305

    Additionaly I found this
    http://docs.woothemes.com/document/show-cart-contents-total/

    So where do I add the HTML
    <!–
    cart->get_cart_url(); ?>” title=”<?php _e( ‘View your shopping cart’ ); ?>”><?php echo sprintf (_n( ‘%d item’, ‘%d items’, WC()->cart->cart_contents_count ), WC()->cart->cart_contents_count ); ?> – <?php echo WC()->cart->get_cart_total(); ?>
    –>

    FUNCTIONS.PHP
    /*
    <?php
    // Ensure cart contents update when products are added to the cart via AJAX (place the following in functions.php)
    add_filter( ‘woocommerce_add_to_cart_fragments’, ‘woocommerce_header_add_to_cart_fragment’ );
    function woocommerce_header_add_to_cart_fragment( $fragments ) {
    ob_start();
    ?>
    cart->get_cart_url(); ?>” title=”<?php _e( ‘View your shopping cart’ ); ?>”><?php echo sprintf (_n( ‘%d item’, ‘%d items’, WC()->cart->cart_contents_count ), WC()->cart->cart_contents_count ); ?> – <?php echo WC()->cart->get_cart_total(); ?>
    <?php

    $fragments[‘a.cart-contents’] = ob_get_clean();

    return $fragments;
    }*/

    • This reply was modified 9 years, 3 months ago by handelsmann.
    #506752

    Hi!

    Please note that this request is more related to the WooCommerce plugin rather than the Enfold theme (you’ll see the same result if you activate the default WP theme), that being said i was able to find a snippet and i modified it to work with Enfold, try adding the following to your theme / child theme:

    add_action( 'woocommerce_single_product_summary', 'avia_woocommerce_total_product_price', 31 );
    function avia_woocommerce_total_product_price() {
        global $woocommerce, $product;
        ?>
            <script>
                jQuery(function($){
                	$(window).load(function() {
    	                var price = <?php echo $product->get_price(); ?>,
    	                    currency = '<?php echo get_woocommerce_currency_symbol(); ?>';
    	                
    	                setTimeout(function(){
    		                $('.minus, .plus').on('click', function(){
    		                	value = $('[name=quantity]').val();
    
    		                    if (!(value < 1)) {
    		                        var product_total = parseFloat(price * value);
    
    		                        $('.amount').html( currency + product_total.toFixed(2));
    		                    }
    		                });
    	            	},20);	
                    });
                });
            </script>
        <?php
    }

    Regards,
    Josue

    #506861

    Hi Josue,

    thank you so much man. Appreciate that from honestly from the heart as I know there is a lot. So I added the script BUT IT DOESN’T INFLUENCE the shopping cart.

    Do I maybe have to change something additionaly in the arrangement of the shopping cart to display the result of that function
    or is it solved directly.

    For e.g. I found a price.php for single-product looking like that

    <?php
    /**
    * Single Product Price, including microdata for SEO
    *
    * @author WooThemes
    * @package WooCommerce/Templates
    * @version 1.6.4
    */

    if ( ! defined( ‘ABSPATH’ ) ) {
    exit; // Exit if accessed directly
    }

    global $product;

    ?>
    <div itemprop=”offers” itemscope itemtype=”http://schema.org/Offer”&gt;

    <p class=”price”><?php echo $product->get_price_html(); ?></p>

    <meta itemprop=”price” content=”<?php echo $product->get_price(); ?>” />
    <meta itemprop=”priceCurrency” content=”<?php echo get_woocommerce_currency(); ?>” />
    <link itemprop=”availability” href=”http://schema.org/&lt;?php echo $product->is_in_stock() ? ‘InStock’ : ‘OutOfStock’; ?>” />

    </div>

    Thank you Josue

    Stephan

    #506867

    Hm, no, this need to be done using JavaScript, i tested the snippet on my local install and it did work, can you please create us a WordPress administrator account? post it here as a private reply.

    #506916

    Hey Josue,

    ok. It should then work. You have that admin account. I post the login in the private reply.

    Best Stephan

    #507332

    Done, check it.

    #507616

    Man, you become my personal hero. What did you change? AWESOME. So just two things:

    1) The standard starts with 139,00 € – your math puts currnency first and use dot instead of comma.
    Where can I change that?

    2) Just for the idea (as you already have done a BIG SUPPORT) – is it very special to have what I described in the first request
    € 15,- | € 15,-
    € 15,- | € 30,-
    instead of only single price. Just tell me where I can change it by request.

    BIG HUG MAN.

    #508072

    OK i modified the code to keep the original format. Regarding 2) what you want is the original price to stay as it is and when additional units are added a second number should appear at its right?

    #508089

    Thank you so much Josue,

    2) Yes exactly. If you tell me where or how to change I can make it by request.
    Thanks Stephan

    #508125

    Ok done, here’s the final code:

    add_action( 'wp_head', 'avia_woocommerce_total_product_price', 31 );
    function avia_woocommerce_total_product_price() {
        if(is_singular('product')){
        global $woocommerce, $product;
        ?>
            <script>
                jQuery(function($){
                	$(window).load(function() {
    	                var price = <?php echo $product->get_price(); ?>,
    	                    currency = '<?php echo get_woocommerce_currency_symbol(); ?>';
    	                
    			
    			$('<span class="final_total"></span>').insertAfter($('.single_variation'));
    
    	                setTimeout(function(){
    		                $('.minus, .plus').on('click', function(){
    		                	value = $('[name=quantity]').val();
    
    		                    if (!(value < 1)) {
    		                        var product_total = parseFloat(price * value),
    					    final_total   = product_total.toFixed(2).replace('.', ',') + ' ' + currency;
    
    					    $('.final_total').html(final_total);
    		                    }
    				   $('.final_total').toggle(!(value <= 1));
    		                });
    	            	},20);	
                    });
                });
            </script>
        <?php
        } 
    }

    To style the final price you can use a CSS code like this:

    .final_total{
       color: red;
    }
    #508261

    Hey Josue,

    you are definitely special man. Thanks for the final step.

    BUT SOMETHING WENT WRONG with that.
    1) The math is somehow based on a single price of $69 by multiplying but should work on the individual price itself
    2) The total amount is displayed not € 15,- | € 30,- (see pics in the post) but
    € 15, in BIG RED
    € 30,- Enthält 19% Mwst. in SMALL BLACK
    If this becomes too complicated then lets go back to the solution from above man.
    You already helped me with that.

    Best Stephan

    #508717

    I don’t really understand what you want to be honest.

    Best regards,
    Josue

    #508882

    Hey Josue,

    didn’t you see the screenshots from September 18? It looked like we are close to it .

    Will attach you again the actual menue so that you can see the difference.
    Multiplying is not in the same line € 99,- | € 198,- and the math in the line below isn’t correct.
    €99- x 2 is not € 138,-

    Thank you so much.

    Best Stephan

    #508890

    BTW: the math problem occurs with the old solution too. Somehow it always refers to a basic price of € 69,-. When it becomes €99,- or €199,- the price for two is always € 138,-

    #509309

    Hey!

    Yes, i see what you were referring to, i tweaked the code to work with variable prices now, check it.

    add_action( 'wp_head', 'avia_woocommerce_total_product_price', 31 );
    function avia_woocommerce_total_product_price() {
    	if(is_singular('product')){
    		global $woocommerce, $product;
    		?>
    		<script>
    		jQuery(function($){
    			$(window).load(function() {
    
    				var finalTotal = $('<span class="final_total"></span>').insertAfter($('.single_variation'));
    				var currency = '<?php echo get_woocommerce_currency_symbol(); ?>';
    
    				var getCurrentPrice = function(){
    					return parseInt($('.summary .price .amount:last').text());
    				};
    
    				var updateFinalPrice = function(){
    					var value = $('[name=quantity]').val();
    
    					if (!(value < 1)) {
    						var productTotal 	  = parseFloat(getCurrentPrice() * value);
    						var finalTotalValue   = productTotal.toFixed(2).replace('.', ',') + ' ' + currency;
    
    						finalTotal.html(finalTotalValue);
    					}
    					finalTotal.toggle(!(value <= 1));
    				};
    
    				setTimeout(function(){
    					$('.minus, .plus').on('click', updateFinalPrice);
    					$('[name=quantity]').on('change', updateFinalPrice);
    				},20);	
    
    				$('#format, #druckart').on('change', function(){
    					finalTotal.hide();
    				});
    
    			});
    		});
    		</script>
    		<?php
    	} 
    }

    Regards,
    Josue

    #509311

    Hi Josue,

    yes – the math seems to work. But the prices are still in two different lines.

    But if thats not possible to do it in onen line € 15,- | € 30,- BOTH IN RED as it is shown in the screenshot – no prob.

    Thank you for that. Appreciate from the heart.

    Best Stephan

    #509325

    Done, i added/modified some of your code in child style.css.

    #509484

    Hey Josue,

    this is damn great. You made it. Thanks from the heart. Yes !!!!

    Josue, wo closing things
    1) Can we have that “Enthält 19% Mwst.” in the line below with a </ br>?
    2) Can you tell me, what you changed in style.css??

    I knew we (YOU) could solve this. You are special mate.
    Thank you so much.

    Best Stephan

    #509486

    Hey!

    1. Add this to style.css:

    .woocommerce_de_versandkosten:before {
        content: "Enthält 19% Mwst.";
        display: block;
    }

    2. Look for final_total in style.css.

    Cheers!
    Josue

    #509506

    Thaaanks.

    :-) – Double Tax Display

    Cheers!
    Stephan

    #509574

    Hm, that’s weird, im not getting that on my end – http://screencast.com/t/kI2ptDYv3

    Regards,
    Josue

    #509577

    Emptied cache, did a DNS flush, started computer again – but same result – in FIREFOX as well as CHROME

    Strange. Don’t know what to do.

    Regards Stephan

    #509581

    Hm, try adding this too:

    .single_variation_wrap span.woocommerce-de_price_taxrate {
        display: none !important;
    }
    #509587

    Yes. This is it. Yeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeess!!
    Thank you soooo much.
    How awesome is this? !

    Again – Thank you Josue. .
    Stephan

    #509594

    You are welcome, glad to help :)

    Regards,
    Josue

Viewing 30 posts - 1 through 30 (of 33 total)
  • The topic ‘Single price | Total price display in the cart’ is closed to new replies.