• Resolved spirit1nfernal

    (@spirit1nfernal)


    Hello.

    I’ve been stuck for a few days with such easy thing as how to get proper refresh cart after changing quantity of products, that already added to cart. For purposes of design custom theme I do some modifications in copied files.
    What done already:
    1) Upgraded cart.js

    var cart = { 
       this.qty_click = this.qty_click.bind(this);
    			$(document).on(
    				'click',
    				'.quantity img',
    				this.qty_click);
    : function (evt) {
    						var $clicked = $(evt.target);
    						var qty = $('.quantity').find('.qty');
    						var currVal = qty.val();
    						var $form = $('.woocommerce #doorCart');
    
    						$('<input />').attr('type', 'hidden')
    							.attr('name', 'update_cart')
    							.attr('value', 'Update Cart')
    							.appendTo($form);
    
    						if ($clicked.is('.minus')) {
    							evt.preventDefault();
    							if (currVal > 0) {
    								var newVal = parseFloat(qty.val()) - 1;
    							} else {
    								newVal = 0;
    							}
    						};
    						if ($clicked.is('.plus')) {
    							evt.preventDefault();
    								newVal = parseFloat(qty.val()) + 1;
    						};
    
    							qty.attr('data-quantity', newVal).change();
    							qty.attr( 'value', newVal ).change();
    	

    2) added custom filter in functions.php

    add_action( 'woocommerce_after_cart', 'custom_after_cart' );
    function custom_after_cart() {
    	echo '<script>
    	jQuery(document).ready(function($) {
    		var upd_cart_btn = $(".update-cart-button");
    		upd_cart_btn.hide();
    		$("#doorCart").find(".qty").on("change", function(){
    			upd_cart_btn.trigger("wc_update_cart");
    		});
    	});
    	</script>';
    }

    3) edited quantity-input.php

    <img src="<?php echo get_template_directory_uri() ?>/assets/img/minus.png" alt="" name="minus" class="minus copy-<?php echo esc_attr( $input_value ); ?>"/>
    	<input type="number" step="<?php echo esc_attr( $step ); ?>" min="<?php echo esc_attr( $min_value ); ?>" max="<?php echo esc_attr( $max_value ); ?>" name="<?php echo esc_attr( $input_name ); ?>" value="<?php echo esc_attr( $input_value ); ?>" data-quantity="<?php echo esc_attr( $input_value ); ?>"  title="<?php echo esc_attr_x( 'Qty', 'Product quantity input tooltip', 'woocommerce' ) ?>" class="input-text qty text exo2Medium" size="4" pattern="<?php echo esc_attr( $pattern ); ?>" inputmode="<?php echo esc_attr( $inputmode ); ?>"/>
    <img src="<?php echo get_template_directory_uri() ?>/assets/img/plus.png" alt="" name="plus" class="plus copy-<?php echo esc_attr( $input_value ); ?>"/>

    What I expects from all of this?
    I need that cart will b able to refresh and store changes after all user-driven changes made. But this is not happen. Quantity changes, but not stores, total price didn’t changes at all.

    Is it possible to find somewhere materials, how this could properly be done? I have tried to search for a few days, but still have no results.

    As all it doing at local computer I can’t provide link to the site for a live demo.

    Status report is following:

    
    ### WordPress Environment ###
    
    Home URL: https://doorstorewp
    Site URL: https://doorstorewp
    WC Version: 2.6.14
    Log Directory Writable: ?
    WP Version: 4.7.2
    WP Multisite: –
    WP Memory Limit: 2 GB
    WP Debug Mode: –
    WP Cron: ?
    Language: ru_RU
    
    ### Server Environment ###
    
    Server Info: Apache
    PHP Version: 7.1.0
    PHP Post Max Size: 100 MB
    PHP Time Limit: 180
    PHP Max Input Vars: 1000
    cURL Version: 7.51.0
    OpenSSL/1.0.2j
    
    SUHOSIN Installed: –
    MySQL Version: 5.7.16
    Max Upload Size: 100 MB
    Default Timezone is UTC: ?
    fsockopen/cURL: ?
    SoapClient: ?
    DOMDocument: ?
    GZip: ?
    Multibyte String: ?
    Удалить запись: ?
    Удалённое получение: ?
    
    ### Database ###
    
    WC Database Version: 2.6.14
    : 
    woocommerce_sessions: ?
    woocommerce_api_keys: ?
    woocommerce_attribute_taxonomies: ?
    woocommerce_downloadable_product_permissions: ?
    woocommerce_order_items: ?
    woocommerce_order_itemmeta: ?
    woocommerce_tax_rates: ?
    woocommerce_tax_rate_locations: ?
    woocommerce_shipping_zones: ?
    woocommerce_shipping_zone_locations: ?
    woocommerce_shipping_zone_methods: ?
    woocommerce_payment_tokens: ?
    woocommerce_payment_tokenmeta: ?
    MaxMind GeoIP Database: ? Базы данных MaxMind GeoIP не существует - геолокация не будет функционировать. Вы можете скачать это вручную из https://dev.maxmind.com/geoip/legacy/geolite/ и установить в директорию: . Скрольте вниз до \"Downloads\" и выбирайте файл \"Binary / gzip\" рядом с \"GeoLite Country\".
    
    ### Active Plugins (7) ###
    
    Advanced Custom Fields: Repeater Field: от Elliot Condon – 1.1.1
    Advanced Custom Fields: от Elliot Condon – 4.4.11
    Breadcrumb NavXT: от John Havlik – 5.6.0
    Oi Yandex.Maps for WordPress: от Alexei Isaenko – 2.42
    Regenerate Thumbnails: от Alex Mills (Viper007Bond) – 2.2.6
    TinyMCE Advanced: от Andrew Ozz – 4.4.3
    WooCommerce: от WooThemes – 2.6.14
    
    ### Settings ###
    
    Force SSL: –
    Currency: RUB (?)
    Currency Position: right_space
    Thousand Separator: ,
    Decimal Separator: .
    Number of Decimals: 0
    
    ### API ###
    
    API Enabled: ?
    
    ### WC Pages ###
    
    Ссылка магазина: #4 - /%d0%b2%d0%b8%d1%82%d1%80%d0%b8%d0%bd%d0%b0/
    Корзина: #5 - /%d0%ba%d0%be%d1%80%d0%b7%d0%b8%d0%bd%d0%b0/
    Оформление заказа: #6 - /%d0%be%d1%84%d0%be%d1%80%d0%bc%d0%bb%d0%b5%d0%bd%d0%b8%d0%b5-%d0%b7%d0%b0%d0%ba%d0%b0%d0%b7%d0%b0/
    Мой аккаунт: ? Страница не задана
    
    ### Taxonomies ###
    
    Product Types: external (external)
    grouped (grouped)
    simple (simple)
    variable (variable)
    
    ### Theme ###
    
    Name: DoorStore
    Version: 1.0.0
    Author URL: 
    Child Theme: ? 
    WooCommerce Support: ?
    
    ### Templates ###
    
    Overrides: DoorStore/woocommerce/cart\cart-empty.php
    DoorStore/woocommerce/cart\cart-totals.php
    DoorStore/woocommerce/cart\cart.php
    DoorStore/woocommerce/cart\proceed-to-checkout-button.php
    DoorStore/woocommerce/content-product.php
    DoorStore/woocommerce/content-single-product.php
    DoorStore/woocommerce/global\quantity-input.php
    DoorStore/woocommerce/loop\add-to-cart.php версия - устарела. Версия ядра 2.5.0
    DoorStore/woocommerce/notices\error.php
    DoorStore/woocommerce/notices\notice.php
    DoorStore/woocommerce/notices\success.php
    DoorStore/woocommerce/single-product.php
    

    thanks in advance. hope you can help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter spirit1nfernal

    (@spirit1nfernal)

    ignoring is a bliss, thanks a lot

    That’s quite an advanced chunk of code for a typical forum question, and would require significant time for the typical volunteer helper to provide a response. There are few volunteers and many questions.

    The WooCommerce team seem to avoid supporting custom developments, I suppose it would be an open-ended commitment to respond to each request.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Help with proper refresh cart’ is closed to new replies.