Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

E-Commerce Modules /

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

Product attributes in ecommerce module


Reply


5 Posts   2865 Views

Avatar
Cuba

Community Member, 12 Posts

10 August 2009 at 12:21am

Edited: 10/08/2009 12:28am

Hello!
The e-commerce module is pretty complex and I'm realizing that i should ask you who might have build it before I go crazy.

I'm wondering how I can implement attributes for a product. For instance, one product can be in different colors that shouldn't affect the price. However the user must chose a color on the product-page before adding to cart. I can't say its obvious how to implement such functionality. I would very much appreciate all the help you can give. I've started to look at the orderattribute class but it's still not obvious.

Another, more secondary, question is why it is not possible to add several variations of the same product to your cart. I've noticed that if I add a product variation to my cart, and then add the same product with another type of variation, the former addition just disappears. I just got one item in my cart and it's the latest product variation addition. The first addition is gone. Weird right? How can i approach this?

I'll be glad for some pointers!
Thanks

Avatar
Cuba

Community Member, 12 Posts

10 August 2009 at 12:57am

Ok i Solved my secondary question.

What I did was that in shoppingcart.php i edited the funtion add_new_item so that it checks if you are trying to add a productvariation or a product:

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

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

Further i added functions in productvariation.php, in class "ProductVariation_OrderItem". I overrode the removeallLink, removeLink, addLink, setquantityLink that it inherited from product_orderitem.
ex: function removeallLink() {
       return ShoppingCart_Controller::remove_all_item_link($this->_productVariationID);
    }

Now it seems to work.

Now if i only could add product attributes in a simple way....

Avatar
Polawat

Community Member, 4 Posts

5 October 2009 at 5:54am

Thanks a lot for this! I got it working now. May I add that you also need to add the function getProductVariationID() as well.

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

Cheers!

Avatar
bubaphex

Community Member, 12 Posts

9 October 2009 at 1:39pm

how did you get on with Product attributes, did you find a solution ?

Avatar
haantje72

Community Member, 69 Posts

9 July 2010 at 6:41am

Ive got it all working: see post

http://www.silverstripe.org/e-commerce-module-forum/show/288081?showPost=288136