Digital experiences for all disciplines
New Landing › How can we help? › Atelier › Cart widget on navigation shows product without VAT
New Landing › How can we help? › Atelier › Cart widget on navigation shows product without VAT
- This topic has 6 replies, 3 voices, and was last updated 8 years by David Martin – Support.
-
Posted in: Atelier
-
May 13, 2016 at 2:13 pm #267328
Hello swiftideas team,
Currently my cart widget on the navigation bar / header shows the products added to the it without VAT.
https://www.tequilaysoledad.com/shop/
Could you pls tell me how can I display them incl. VAT?
thanks in advance
May 16, 2016 at 3:26 pm #267802Hi,
Please install and activate the supplied child theme.
Within the child theme
functions.php
file, please add this:Note: The changes will not take effect until you add/remove/update an item from the cart to trigger the AJAX to reload the cart contents.
/* ADD TO CART HEADER RELOAD ================================================== */ if ( ! function_exists( 'sf_woo_header_add_to_cart_fragment' ) ) { function sf_woo_header_add_to_cart_fragment( $fragments ) { global $woocommerce; $sf_options = sf_get_theme_opts(); ob_start(); $show_cart_count = false; if ( isset( $sf_options['show_cart_count'] ) ) { $show_cart_count = $sf_options['show_cart_count']; } if ( sf_theme_opts_name() == "sf_atelier_options" ) { $cart_total = '<span class="menu-item-title">' . __( "Cart" , "swiftframework" ) . '</span>'; } else { $cart_total = WC()->cart->get_cart_total(); } $cart_count = $woocommerce->cart->cart_contents_count; $cart_count_text = sf_product_items_text( $cart_count ); $cart_count_text_alt = sf_product_items_text( $cart_count, true ); $view_cart_icon = apply_filters( 'sf_view_cart_icon', '<i class="ss-view"></i>' ); $checkout_icon = apply_filters( 'sf_checkout_icon', '<i class="ss-creditcard"></i>' ); $go_to_shop_icon = apply_filters( 'sf_go_to_shop_icon', '<i class="ss-cart"></i>' ); $extra_class = ""; if ( $cart_count != "0" ) { $extra_class .= "cart-not-empty "; } ?> <li class="parent shopping-bag-item <?php echo $extra_class; ?>"> <?php if ( $show_cart_count ) { ?> <a class="cart-contents" href="<?php echo esc_url($woocommerce->cart->get_cart_url()); ?>" title="<?php _e( 'View your shopping cart', 'swiftframework' ); ?>"> <?php echo apply_filters( 'sf_header_cart_icon', '<i class="ss-cart"></i>' ); ?><span class="cart-text"><?php _e( "Cart", "swiftframework" ); ?></span><?php echo $cart_total; ?><span class="num-items cart-count-enabled"><?php echo $cart_count_text_alt; ?></span></a> <?php } else { ?> <a class="cart-contents" href="<?php echo esc_url($woocommerce->cart->get_cart_url()); ?>" title="<?php _e( 'View your shopping cart', 'swiftframework' ); ?>"><?php echo apply_filters( 'sf_header_cart_icon', '<i class="ss-cart"></i>' ); ?><span class="cart-text"><?php _e( "Cart", "swiftframework" ); ?></span><?php echo $cart_total; ?><span class="num-items"><?php echo $cart_count_text_alt; ?></span></a> <?php } ?> <ul class="sub-menu"> <li> <div class="shopping-bag" data-empty-bag-txt="<?php _e( 'Your cart is empty.', 'swiftframework' ); ?>" data-singular-item-txt="<?php _e( 'item in the cart', 'swiftframework' ); ?>" data-multiple-item-txt="<?php _e( 'items in the cart', 'swiftframework' ); ?>"> <div class="loading-overlay"><i class="sf-icon-loader"></i></div> <?php if ( $cart_count != "0" ) { ?> <div class="bag-header"><?php echo $cart_count_text; ?> <?php _e( 'in the cart', 'swiftframework' ); ?></div> <div class="bag-contents"> <?php foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { ?> <?php $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key ); $product_title = $_product->get_title(); $price = apply_filters( 'woocommerce_cart_item_price', $woocommerce->cart->get_product_price( $_product ), $cart_item, $cart_item_key ); ?> <?php $variation_id_class = ''; if ( $cart_item['variation_id'] > 0 ) $variation_id_class = ' product-var-id-' . $cart_item['variation_id']; if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_cart_item_visible', true, $cart_item, $cart_item_key ) ) { ?> <div class="bag-product clearfix product-id-<?php echo $cart_item['product_id']; ?><?php echo $variation_id_class; ?>"> <figure><a class="bag-product-img" href="<?php echo get_permalink( $cart_item['product_id'] ); ?>"><?php echo $_product->get_image(); ?></a> </figure> <div class="bag-product-details"> <div class="bag-product-title"> <a href="<?php echo get_permalink( $cart_item['product_id'] ); ?>"> <?php echo apply_filters( 'woocommerce_cart_widget_product_title', $product_title, $_product ); ?></a> </div> <div class="bag-product-price"><?php _e( "Unit Price:", "swiftframework" ); ?> <?php echo $price; ?></div> <div class="bag-product-quantity"><?php _e( 'Quantity:', 'swiftframework' ); ?> <?php echo $cart_item['quantity']; ?></div> </div> <a href="#" class="remove-product remove" data-ajaxurl="<?php echo admin_url( 'admin-ajax.php' ); ?>" data-product-id="<?php echo $cart_item['product_id'];?>" data-variation-id="<?php echo $cart_item['variation_id'];?>" data-product-qty="<?php echo $cart_item['quantity'];?>" title="<?php echo __( 'Remove this item', 'swiftframework' ); ?>">×</a> </div> <?php } ?> <?php } ?> </div> <?php if ( sf_theme_opts_name() == "sf_atelier_options" || sf_theme_opts_name() == "sf_uplift_options" ) { ?> <div class="bag-total"> <?php if ( class_exists( 'Woocommerce_German_Market' ) ) { ?> <span class="total-title"><?php _e( "Total incl. tax", "swiftframework" ); ?></span> <?php } else { ?> <span class="total-title"><?php _e( "Total", "swiftframework" ); ?></span> <?php } ?> <span class="total-amount"><?php echo wc_price( round($woocommerce->cart->cart_contents_total + $woocommerce->cart->tax_total, 2) ); ?></span> </div> <?php } ?> <div class="bag-buttons"> <a class="sf-button standard sf-icon-reveal bag-button" href="<?php echo esc_url( $woocommerce->cart->get_cart_url() ); ?>"> <?php echo $view_cart_icon; ?> <span class="text"><?php _e( 'View cart', 'swiftframework' ); ?></span> </a> <a class="sf-button standard sf-icon-reveal checkout-button" href="<?php echo esc_url( $woocommerce->cart->get_checkout_url() ); ?>"> <?php echo $checkout_icon; ?> <span class="text"><?php _e( 'Checkout', 'swiftframework' ); ?></span> </a> </div> <?php } else { ?> <div class="bag-empty"><?php _e( 'Your cart is empty.', 'swiftframework' ); ?></div> <?php } ?> </div> </li> </ul> </li> <?php $fragments['.shopping-bag-item'] = ob_get_clean(); return $fragments; } add_filter( 'add_to_cart_fragments', 'sf_woo_header_add_to_cart_fragment' ); }
June 23, 2016 at 11:40 am #276648Hi Martin,
a quick one here. Is there perhaps some option in the theme that controls this behaviour?
Because I have atelier on 2 pages. On https://www.tequilaysoledad.com/ the total price on the cart widget of the navigation bar is shown without VAT and on https://www.bloomagedaydream.com/ it does shows it including the VAT.
Any hint or idea before I add your suggested code to functions.php of my child theme?
kind regards
Alonso
June 25, 2016 at 12:08 pm #277121Hi Alonso,
Please check your WooCommerce settings – as there are settings that control the prices inclusive of VAT.
– Ed
June 27, 2016 at 10:31 am #277310Hi Ed and Martin,
1. Martin’s code works perfectly. Thanks for that!
2. Ed, I compared the settings of both domains and the only difference we had and make indeed the difference between displaying the total with or without VAT was on WOOCOMMERCE > SETTINGS > TAX -> Prices Entered With Tax.
If you choose: “Yes, I will enter prices inclusive of tax” the display of the total on the cart-widget includes the VAT and thus is correct.
If you choose: “No, I will enter prices exclusive of tax” the display of the total does not includes the VAT and it is confusing cause the other products listed on the cart do include VAT so the sum of all of them is larger than the value displayed as a total.
For now, I am using Martin’s solution but perhaps this can help you on a future update ๐
kind regards
Alonso
June 27, 2016 at 10:32 am #277311Solved. ๐
June 27, 2016 at 10:38 am #277314Hi Alonso,
Glad that helped you out for the time being, I’ll pass this back to Ed for review and possible inclusion in the future updates.
Thanks.
-
Posted in: Atelier
You must be logged in and have valid license to reply to this topic.