Jump to:

2081 Posts in 1001 Topics by 452 members

E-Commerce Modules

SilverStripe Forums » E-Commerce Modules » Product attributes in ecommerce module

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: 2753 Views
  • Cuba
    Avatar
    Community Member
    12 Posts

    Product attributes in ecommerce module Link to this post

    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

  • Cuba
    Avatar
    Community Member
    12 Posts

    Re: Product attributes in ecommerce module Link to this post

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

  • Polawat
    Avatar
    Community Member
    4 Posts

    Re: Product attributes in ecommerce module Link to this post

    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!

  • bubaphex
    Avatar
    Community Member
    12 Posts

    Re: Product attributes in ecommerce module Link to this post

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

  • haantje72
    Avatar
    Community Member
    69 Posts
    2753 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.