-
AuthorPosts
-
September 18, 2015 at 10:02 am #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
September 18, 2015 at 12:49 pm #505421Hey 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!
YigitSeptember 18, 2015 at 8:48 pm #505769Hi 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.jpgRegards
StephanSeptember 21, 2015 at 6:56 am #506229Hey!
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!
IsmaelSeptember 21, 2015 at 9:18 am #506283Hey 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
September 21, 2015 at 9:51 am #506305Additionaly 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.
September 22, 2015 at 1:41 am #506752Hi!
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,
JosueSeptember 22, 2015 at 10:00 am #506861Hi 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”><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/<?php echo $product->is_in_stock() ? ‘InStock’ : ‘OutOfStock’; ?>” /></div>
Thank you Josue
Stephan
September 22, 2015 at 10:18 am #506867Hm, 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.
September 22, 2015 at 11:32 am #506916Hey Josue,
ok. It should then work. You have that admin account. I post the login in the private reply.
Best Stephan
September 22, 2015 at 8:37 pm #507332Done, check it.
September 23, 2015 at 11:41 am #507616Man, 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.
September 23, 2015 at 8:31 pm #508072OK 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?
September 23, 2015 at 10:15 pm #508089Thank you so much Josue,
2) Yes exactly. If you tell me where or how to change I can make it by request.
Thanks StephanSeptember 24, 2015 at 1:36 am #508125Ok 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; }
September 24, 2015 at 10:42 am #508261Hey 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
September 24, 2015 at 11:28 pm #508717I don’t really understand what you want to be honest.
Best regards,
JosueSeptember 25, 2015 at 10:33 am #508882Hey 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
September 25, 2015 at 10:39 am #508890BTW: 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,-
September 25, 2015 at 11:40 pm #509309Hey!
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,
JosueSeptember 25, 2015 at 11:51 pm #509311Hi 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
September 26, 2015 at 12:43 am #509325Done, i added/modified some of your code in child style.css.
September 26, 2015 at 1:02 pm #509484Hey 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
September 26, 2015 at 1:10 pm #509486Hey!
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!
JosueSeptember 26, 2015 at 2:47 pm #509506Thaaanks.
:-) – Double Tax Display
Cheers!
StephanSeptember 26, 2015 at 8:52 pm #509574Hm, that’s weird, im not getting that on my end – http://screencast.com/t/kI2ptDYv3
Regards,
JosueSeptember 26, 2015 at 9:12 pm #509577Emptied 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
September 26, 2015 at 10:34 pm #509581Hm, try adding this too:
.single_variation_wrap span.woocommerce-de_price_taxrate { display: none !important; }
September 26, 2015 at 11:06 pm #509587Yes. This is it. Yeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeess!!
Thank you soooo much.
How awesome is this? !Again – Thank you Josue. .
StephanSeptember 26, 2015 at 11:34 pm #509594You are welcome, glad to help :)
Regards,
Josue -
AuthorPosts
- The topic ‘Single price | Total price display in the cart’ is closed to new replies.