Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Changes in View Cart
 
Reply
   X-Cart forums > X-Cart 5 > Modules and themes (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 06-05-2018, 04:26 AM
 
Soptareanu @Alex Soptareanu @Alex is offline
 

Advanced Member
  
Join Date: Apr 2018
Posts: 39
 

Default Changes in View Cart

Hello, i do some changes in my view-cart layout in order to looks like in capture. For that i replace quantity_box.twig with my new implementation.
This is my own quantity_box.twig file
HTML Code:
{## # Main element (input) # # @ListChild (list="product.quantity-box", weight="20") #} <div class="fdmteam_quantity"> <input type="hidden" class="{{ this.getClass() }}" id="{{ this.getBoxId() }}" value="{{ this.getBoxValue() }}" name="{{ this.getBoxName() }}" > <span class="fdmteam_quantity_value" id="count-{{ this.getBoxId() }}"> {{ this.getBoxValue() }} </span> <span class="fdmteam_quantity_label"> {{ t(this.getBoxTitle()) }} </span> </div> <div class="fdmteam_quantity_plus" id="plus-{{ this.getBoxId() }}"></div> <div class="fdmteam_quantity_minus" id="minus-{{ this.getBoxId() }}"></div> <script> document.body.addEventListener('click', function(event){ var _target_p = "plus-{{ this.getBoxId() }}" ; var _target_m = "minus-{{ this.getBoxId() }}" ; var _input = "{{ this.getBoxId() }}"; var _span = "count-{{ this.getBoxId() }}"; if(event.target.id == _target_p){ var i = parseInt(document.getElementById(_input).value) ; i++; document.getElementById(_span).innerHTML = i; document.getElementById(_input).value = i; // do update cart !! }else if(event.target.id == _target_m){ var i = parseInt(document.getElementById(_input).value) ; i--; if(!i){ return false; }else{ document.getElementById(_span).innerHTML = i; document.getElementById(_input).value = i; // do update cart !! } } }); </script>
The question is how to put updateCart trigger in order to work properly as default implementation. I want to update quantity of item when i press + - button.
Attached Thumbnails
Click image for larger version

Name:	cartViw.PNG
Views:	33
Size:	26.6 KB
ID:	5161  
__________________
Soptareanu Alex
Reply With Quote
  #2  
Old 06-06-2018, 05:18 AM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

X-Cart team
  
Join Date: Jan 2009
Posts: 2,423
 

Default Re: Changes in View Cart

Hi @Alex,

To achieve that try to submit the quantity form using JQuery, once you hit +/- button. X-Cart should catch this form submit and do that via AJAX, so you should get desired result.

If it does not work, try to add 'watcher' CSS class to your +/- buttons and remove form submit via JQuery.

Please, keep me posted about results.

Tony
__________________
Found a bug in X-Cart? Post it to our bug tracker!
Know how to make X-Cart better? Suggest an idea!
Reply With Quote
  #3  
Old 06-06-2018, 11:37 PM
 
Soptareanu @Alex Soptareanu @Alex is offline
 

Advanced Member
  
Join Date: Apr 2018
Posts: 39
 

Default Re: Changes in View Cart

Quote:
Originally Posted by tony_sologubov
Hi @Alex,

To achieve that try to submit the quantity form using JQuery, once you hit +/- button. X-Cart should catch this form submit and do that via AJAX, so you should get desired result.

If it does not work, try to add 'watcher' CSS class to your +/- buttons and remove form submit via JQuery.

Please, keep me posted about results.

Tony

I put "watcher" css class on +/- buttons such as
HTML Code:
<div class="watcher fdmteam_quantity_plus" id="plus-{{ this.getBoxId() }}"></div>
but still doesn't works.
__________________
Soptareanu Alex
Reply With Quote
  #4  
Old 06-19-2018, 01:43 AM
 
Soptareanu @Alex Soptareanu @Alex is offline
 

Advanced Member
  
Join Date: Apr 2018
Posts: 39
 

Default Re: Changes in View Cart

Quote:
Originally Posted by tony_sologubov
Hi @Alex,

To achieve that try to submit the quantity form using JQuery, once you hit +/- button. X-Cart should catch this form submit and do that via AJAX, so you should get desired result.

If it does not work, try to add 'watcher' CSS class to your +/- buttons and remove form submit via JQuery.

Please, keep me posted about results.

Tony

I put this function jQuery('.update-quantity').submit(); and it works. But i have problem in quick view page if a product has variants because the script is executed for each element and this cause a problem with my increment value (i).
Attached Thumbnails
Click image for larger version

Name:	capture_3.PNG
Views:	33
Size:	131.7 KB
ID:	5168  
__________________
Soptareanu Alex
Reply With Quote
  #5  
Old 06-19-2018, 02:36 AM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

X-Cart team
  
Join Date: Jan 2009
Posts: 2,423
 

Default Re: Changes in View Cart

Hi @Alex,

Thanks for reaching out.

Could you please explain the problem in more detail?

If we talk about quick view product page, I would assume that clicking +/- would just change value in quantity box and would not call jQuery('.update-quantity').submit(); function.

The same happens when you change quantity manually there.

Tony

Quote:
Originally Posted by Soptareanu @Alex
I put this function jQuery('.update-quantity').submit(); and it works. But i have problem in quick view page if a product has variants because the script is executed for each element and this cause a problem with my increment value (i).
__________________
Found a bug in X-Cart? Post it to our bug tracker!
Know how to make X-Cart better? Suggest an idea!
Reply With Quote
  #6  
Old 06-19-2018, 11:43 PM
 
Soptareanu @Alex Soptareanu @Alex is offline
 

Advanced Member
  
Join Date: Apr 2018
Posts: 39
 

Default Re: Changes in View Cart

Quote:
Originally Posted by tony_sologubov
Hi @Alex,

Thanks for reaching out.

Could you please explain the problem in more detail?

If we talk about quick view product page, I would assume that clicking +/- would just change value in quantity box and would not call jQuery('.update-quantity').submit(); function.

The same happens when you change quantity manually there.

Tony
I'm not using the implementation from controller.js . I just put my custom .js directly in my quntity_box.twig. But that .js code affect the quick view page. If I click to change product attribute in quick view then my custom js. is executed more time, and the value of element increment with more than one unit.
__________________
Soptareanu Alex
Reply With Quote
  #7  
Old 06-19-2018, 11:45 PM
 
Soptareanu @Alex Soptareanu @Alex is offline
 

Advanced Member
  
Join Date: Apr 2018
Posts: 39
 

Default Re: Changes in View Cart

Quote:
Originally Posted by Soptareanu @Alex
I'm not using the implementation from controller.js . I just put my custom .js directly in my quntity_box.twig. But that .js code affect the quick view page. If I click to change product attribute in quick view then my custom js. is executed more time, and the value of element increment with more than one unit.
If you can see in the capture, the value of the element become 5 instead of 2.
__________________
Soptareanu Alex
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Modules and themes (X-Cart 5)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 04:08 AM.

   

 
X-Cart forums © 2001-2018