New Landing How can we help? Atelier Cart widget on navigation shows product without VAT

Viewing 7 posts - 1 through 7 (of 7 total)
  • Posted in: Atelier
  • #267328
    pinponketo
    Member
    Post count: 36

    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

    #267802
    David Martin – Support
    Moderator
    Post count: 20834

    Hi,

    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' ); ?>">&times;</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' );
        }
    #276648
    pinponketo
    Member
    Post count: 36

    Hi 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

    #277121
    Swift Ideas – Ed
    Keymaster
    Post count: 15264

    Hi Alonso,

    Please check your WooCommerce settings – as there are settings that control the prices inclusive of VAT.

    – Ed

    #277310
    pinponketo
    Member
    Post count: 36

    Hi 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

    #277311
    pinponketo
    Member
    Post count: 36

    Solved. ๐Ÿ˜‰

    #277314
    David Martin – Support
    Moderator
    Post count: 20834

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

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register