Jump to:

2076 Posts in 857 Topics by 449 members

E-Commerce Modules

SilverStripe Forums » E-Commerce Modules » VARIATION SOLVED: product variation ecommerce 0.6

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: 1915 Views
  • haantje72
    Avatar
    Community Member
    69 Posts

    VARIATION SOLVED: product variation ecommerce 0.6 Link to this post

    I use ss2.4 with ecommerce 0.6 trunk r98047

    I've got a problem with managing the productvariations...

    from post http://silverstripe.org/e-commerce-module-forum/show/266407

    i changed:

    shoppingcart.php on line 116-129

    FROM:

       static function add_new_item(OrderItem $item) {
          $itemsTableIndex = self::items_table_name();
          
          if($serializedItems = Session::get($itemsTableIndex)) {
             foreach($serializedItems as $itemIndex => $serializedItem) {
                if($serializedItem != null) {
                   $unserializedItem = unserialize($serializedItem);
                   if($unserializedItem->hasSameContent($item)) return self::add_item($itemIndex, $item-

    >getQuantity());
                }
             }
          }
          
          self::set_item($item->getProductID(), $item);
       }

    TO:

    function getProductVariationID() {
    return $this->_productVariationID;
    }
          
       static function add_new_item(OrderItem $item) {
          $itemsTableIndex = self::items_table_name();
          
          if($serializedItems = Session::get($itemsTableIndex)) {
             foreach($serializedItems as $itemIndex => $serializedItem) {
                if($serializedItem != null) {
                   $unserializedItem = unserialize($serializedItem);
                   if($unserializedItem->hasSameContent($item)) return self::add_item($itemIndex, $item-

    >getQuantity());
                }
             }
          }
          
          if(($item->getProductVariationID())){
    self::set_item($item->getProductVariationID(), $item);
    }else{
    self::set_item($item->getProductID(), $item);
    }
       }

    In productvariation.php i added on line 108

    function getProductVariationID() {
    return $this->_productVariationID;
    }

    function removeallLink() {
    return ShoppingCart_Controller::remove_all_item_link($this->_productVariationID);
    }

    In OrderItem.php i added on line 48

    function getProductVariationID() {
    return $this->_productVariationID;
    }

    then run an dev/build?flush=1

    Now i can ad multiple variations and normal products without variation in the cart.

    The problem:
    - i can remove the items but not update (eg 1 --> 2 with + or -) from the cart, whatever i do... when i click the + or - i get an blank page htt://mysite.nl/shoppingcart/additem/9 with tab namen HTTP failure 500 - internal server failure instead of getting back to the checkout or productpage and added one more product.

    With adding an product without variation there is no problem

    The site is in devmode with no errors

    Any idea how to solve this?

    Next... how do i get into ss 2.4 into the cms admin section the order reports to change the status???
    With earlier versions you have a reports tab to browse the orders... now with the new version it became the links and no orderreports show up

  • Optic Blaze
    Avatar
    Community Member
    150 Posts

    Re: VARIATION SOLVED: product variation ecommerce 0.6 Link to this post

    Thanks for the help....i had huge problems with the variations.

    About the problem that you have with the variations not updating...i have a workaround.

    1. Go to Product.php line 397 & 401 change the code to read form .....$this->_productID..... to ... $this->_productVariationID
    so in otherwords:

    return ShoppingCart_Controller::add_item_link($this->_productVariationID);

    this therefore changes the behaviour of the entire shopping cart to rather use the variation id as apposed to
    the product id for the transaction. All you have to do when loading a product is to add 1 variation with the same price...
    then the shopping cart works 100%

    2. The only problem i encountered was that when all the products were displayed in thumbnail view, that when you clicked "Add to cart" you got an error, because it did not know which of the variations to choose...i fixed this by forcing the visitor to view all the options...i did this by changing line 32's code to the following code in on the ProductGroupItem.ss page (located under the product folder)

    Code was:

    <p class="quantityBox"><a href="$addLink" title="<% sprintf(_t("ADD","Add &quot;%s&quot; to your cart"),$Title) %>"><% _t("ADDLINK","Add to cart &raquo") %></a></p>

    Code changed to:

    <p class="quantityBox"><a href="$Link" title="<% sprintf(_t("ADD","Add &quot;%s&quot; to your cart"),$Title) %>"><% _t("ADDLINK","View options") %></a></p>

    Hope it helps

  • haantje72
    Avatar
    Community Member
    69 Posts

    Re: VARIATION SOLVED: product variation ecommerce 0.6 Link to this post

    Youre welcome... have been searching on the forum for 2 days. Have not found an good answer yet so tried lots of things and the above code came out. The old post directs in the right direction but isn't complete.

    Your solution works for the variations but throws out the quantity change of the products without variation i noticed!
    There should be an if else code? I'm no real php programmer... still learning and just got it working the right way i want it.

    Product.php line 397 & 401

    CHANGE:
    function addLink() {
          return ShoppingCart_Controller::add_item_link($this->_productID);
       }
       
       function removeLink() {
          return ShoppingCart_Controller::remove_item_link($this->_productID);
       }

    TO:
    function addLink() {
          if ($this->_productVariationID) return ShoppingCart_Controller::add_item_link($this->_productVariationID);
          else return ShoppingCart_Controller::add_item_link($this->_productID);
       }
       
       function removeLink() {
          if ($this->_productVariationID) return ShoppingCart_Controller::remove_item_link($this->_productVariationID);
          else return ShoppingCart_Controller::remove_item_link($this->_productID);

    NOT IT WORKS PERFECTLY. THE VARIATIONS AND THE PRODUCT WITHOUT VARIATION.

    Thanks for reply.

    NOW FIND SOME WAY TO MANAGE THE ORDERS IN THE CMS ADMIN SECTION... still does not show.

  • Optic Blaze
    Avatar
    Community Member
    150 Posts

    Re: VARIATION SOLVED: product variation ecommerce 0.6 Link to this post

    AWESOME!!! Really cool man.

    I got a good news bad news situation for you.

    Good news....the orders work perfect.... the bad news ....only in SS2.3.2

    http://www.silverstripe.org/e-commerce-module-forum/show/262686#post262686

  • haantje72
    Avatar
    Community Member
    69 Posts

    Re: VARIATION SOLVED: product variation ecommerce 0.6 Link to this post

    mmm, oke.
    Where can i download the older version. In my case its no problem... but if it could like to have it on 2.4.

    Maybe there could be a module for or in mysite/ an custom page with classes... pfff.. wow dont know where to start.
    Think 2.3 would be the best option

  • Optic Blaze
    Avatar
    Community Member
    150 Posts
  • haantje72
    Avatar
    Community Member
    69 Posts

    Re: VARIATION SOLVED: product variation ecommerce 0.6 Link to this post

    thanks. 2.3.4 i have now... and it works great.

  • haantje72
    Avatar
    Community Member
    69 Posts

    Re: VARIATION SOLVED: product variation ecommerce 0.6 Link to this post

    Changed some things in the adminsection foor better invoice an email:

    ---------------------

    ----------
    ----------
    OrderInformation.ss

    line 2 added after <thead>
    Order Number $ID

    ***this shows up the order id above the invoice* in the admin section**

    ----------

    line 15

    <% if Link %>
                      
    <a href="$Link" title="<% sprintf(_t("READMORE","Click here to read more on &quot;%s&quot;"),$Title) %>">$TableTitle</a>

    ***shows in the admin section in the invoice the variation***
    ----------

    line 32

    CHANGED:
    <% control Modifiers %>      
    <% if ShowInOrderTable %>         
    <tr id="$IDForTable" class="$ClassForTable">         
    <td colspan="2" scope="row" id="$TitleIdForTable">$TitleForTable</td>         
    <td>&nbsp;</td>         
    <td class="right" id="$ValueIdForTable">$ValueForTable</td>            
    </tr>      
    <% end_if %>   
    <% end_control %>

    TO:

    <% control Modifiers %>
                <% if ShowInTable %>
                   <tr id="$TableID" class="$Classes">
                      <td<% if Link %><% else %> id="$TableTitleID"<% end_if %> colspan="2" scope="row">
                         <% if Link %>
                            <a id="$TableTitleID" href="$Link" title="<% sprintf(_t("READMORE","Click here to read more on &quot;%s&quot;"),$TableTitle) %>">$TableTitle</a>
                         <% else %>
                            $TableTitle
                         <% end_if %>
                      </td>
                      <td>&nbsp;</td>
                      <td class="right" id="$TableTotalID"><% if IsChargable %>$Amount.Nice<% else %>-$Amount.Nice<% end_if %></td>
                      <td class="right remove">
                         <% if CanRemove %>
                            <strong>
                               <a class="ajaxQuantityLink" href="$removeLink" title="<% sprintf(_t("REMOVE","Remove &quot;%s&quot; from your order"),$TableTitle) %>">
                                  <img src="ecommerce/images/remove.gif" alt="x"/>
                               </a>
                            </strong>
                         <% end_if %>
                      </td>
                   </tr>
                <% end_if %>
             <% end_control %>

    ***now the shipping and tax is shown in the invoice admin section***

    ----------
    ----------

    in Order_ReceiptEmail.ss
    line 148
    <% include OrderInformation %>

    REPLACED BY:
    OrderInformation.ss select all coding and paste.
    So <% include OrderInformation %> is replaced by the complete coding of orderinformation...

    didnt know a better way to do so because the include does something strange.

    ***now the email is send with variation, tax, shipping, etc.***

    SO... FIRST EDIT rderInformation.ss BEFORE COPYING THE CODE!!!

    ----------
    ----------
    OrderForm.php line 117

    /**
       
    * Save in the session that the current member wants to use a different shipping address.
       
    */
       
    function useDifferentShippingAddress($data, $form, $request) {
          
    ShoppingCart::set_uses_different_shipping_address(true);
          
    Director::redirectBack();
       
    }

    ***this changes the way in the checkout that the user can switch back to use billingaddress correct***
    ---------

    Thats it for today...

    Hopefully for lots of people usable

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