Jump to:

2088 Posts in 1007 Topics by 455 members

E-Commerce Modules

SilverStripe Forums » E-Commerce Modules » ajaxQuantityField

Discuss about the various e-commerce modules available:
Ecommerce, SS Shop, SilverCart and SwipeStripe
Alternatively, have a look the shared mailinglist.

Moderators: martimiz, Nicolaas, Sean, frankmullenger, biapar, Willr, Ingo, Jedateach, swaiba, simon_w

Page: 1
Go to End
Author Topic: 459 Views
  • janulka
    Avatar
    Community Member
    80 Posts

    ajaxQuantityField Link to this post

    Hello,

    ajaxQuantityField is not working properly for me..

    on Checkout/Cart page:
    when customer changes quantity by typing in the text field, it is sent to server (e.g..../shoppingcart/setquantityitem/235?quantity=25), but the total price is not updated until I manually refresh the page

    on Product page:
    when changing quantity here by typing in the field, absolutely nothing happens..

    can someone help me with this?

    is there possibility for customers to change quantity already when purchasing items, what I mean is to have small text field next to "purchase" button, so they can buy 5 items straight away instead of having to change quantity in cart afterwards?

    Thank you!

  • janulka
    Avatar
    Community Member
    80 Posts

    Re: ajaxQuantityField Link to this post

    Well, I have to remove quantity field from Product.ss and ProductGroupItem.ss since I have no idea how to get this work.

    On Cart.ss, I have added onchange window.location.reload() this way:

    function Field() {
          $size = 3; //make these customisable
          $maxlength = 3;

          $attributes = array(
             'type' => 'text',
             'class' => implode(' ',$this->classes),
             'name' => $this->item->MainID() . '_Quantity',
             'value' => ($this->item->Quantity) ? $this->item->Quantity : "",
             'maxlength' => $maxlength,
             'size' => $size ,
             'disabled' => 'disabled',
             'onchange' => "window.location.reload();"
          );
          
          //IMPROVE ME: hack to use the form field createTag method ...perhaps this should become a form field instead
          $formfield = new FormField('hack');
          return $formfield->createTag('input', $attributes);
       }

    This works - sometimes.. When the server is fast enough to response with quantity update, then it is updated, when it is not fast enough to respond, the page is reloaded without quantity update.

    Plz, I seriously really need help , now with javascript function how to make javascript wait for server response, and then reload page - after the quantity has been sent to server..

  • janulka
    Avatar
    Community Member
    80 Posts

    Re: ajaxQuantityField Link to this post

    and in addition to that, huuge issue with variations, this code:

    function AJAXLinkHiddenField(){
          if($quantitylink = ShoppingCart::set_quantity_item_link($this->item->getProductVariationIDForSerialization(), null,$this->parameters)){
             $attributes = array(
                'type' => 'hidden',
                'class' => 'ajaxQuantityField_qtylink',
                'name' => $this->item->MainID() . '_Quantity_SetQuantityLink',
                'value' => $quantitylink
             );
             $formfield = new FormField('hack');
             return $formfield->createTag('input', $attributes);
          }
       }

    is creating link to change quantity of the productID rather than productVariationID, lets say i have product 200 with variations 55 and 56, changing quantity for both with this server response:

    shoppingcart/setquantityitem/200?quantity=XX , what means that only first variation is changed no matter what!

    459 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.