Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Ecommerce - Product options (sizes/colours/types...) and discounts

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Page: 1
Go to End
Author Topic: 6706 Views
  • freeyland
    Avatar
    Community Member
    22 Posts

    Ecommerce - Product options (sizes/colours/types...) and discounts Link to this post

    From the docs:
    Stage 1. Just a list of options (e.g. red, blue, green, Big, Green, Small), but same weight/price for all
    Stage 2. Different weights, prices and possibly photos could for the types.

    I am making a holiday booking system. For each hotel you will have different rooms (the products). If you chose to go by bus you will be charged an extra price on top of the standard product price. If you go by car, you get a reduction .

    I think the easiest way to do so is to have some kind of admin page where you can administer the different options.
    Then you would need to assign available options to a product.
    Per option you should have the possibility to add or deduct an amount. (So + and - dropdown and maybe also *)
    So when adding product to the cart. You should be able to select from dropdowns the option you want and the price beeing adapted in real time when changing the options.
    You should also be able to have options where you don't assign a price to it. Those options will just be for informational use. (ex. Do you take skilessons yes or no, which period do you want to go).

    Do I need to make a spereate tab for this or do I add them on the go when creating a product? (The way you can add extra formfields to a contactform)
    This has probably to be done with a has_many relationship. In what relation do i need to add the price and the mathematical symbols?

    Anybody have ideas or remarks on how to implement this.

  • Sean
    Avatar
    Forum Moderator
    921 Posts

    Re: Ecommerce - Product options (sizes/colours/types...) and discounts Link to this post

    There is a Product_Attribute class in there I believe, however, it doesn't appear to have been used yet and is only 'stubbed out'. I think basically:

    class MyProduct extends Product {

    static $has_many = array(
    'Attributes' => 'MyProduct_Attribute'
    );

    }

    class MyProduct_Attribute extends DataObject {

    }

    I don't know if it should be a many_many or a has_many, many_many just confuses me...

    Cheers,
    Sean

  • freeyland
    Avatar
    Community Member
    22 Posts

    Re: Ecommerce - Product options (sizes/colours/types...) and discounts Link to this post

    Thx Sean,

    Something which is still not clear for me in ss framework is how to implment such things. I had the same problem with articles. Let say we want to add each article to a specific category.
    I found the following in the docs:

    class Article extends DataObject {
       static $many_many = array(
          "Categories" => "Category",
       );
       
       /**
        * @param DataObjectSet
        */
       function addCategories(additionalCategories) {
          $existingCategories = $this->Categories();
          
          // method 1: Add many by iteration
          foreach($additionalCategories as $category) {
             $existingCategories->add($category);
          }

          // method 2: Add many by ID-List
          $existingCategories->addMany(array(1,2,45,745));
       }
    }

    class Category extends DataObject {
       static $belongs_many_many = array(
          "Articles" => "Article",
       );
    }

    Where do I add the available categories in the admin section? Do I add an extra tab with CMSfields or do I need to make a separate page where you can administer the different categories.

    I know you are working on a blog module. Is there some kind of cloud with tags? If so, how are the administarted?

    thx

  • Sean
    Avatar
    Forum Moderator
    921 Posts

    Re: Ecommerce - Product options (sizes/colours/types...) and discounts Link to this post

    Hi there,

    I don't know a whole lot about the many_many, and belongs_many_many, but I believe this is a step in the direction. Article would extend Page, because you're wanting it to be a page that can be easily created/deleted from within the SS CMS. Category would be extending DataObject because it doesn't require itself to be a page created or deleted in the CMS, and is just exactly that, an object with some data but without specific page requirements.

    I think you are able to use a CheckboxSetField, which should populate with the categories. Although, I'm not entirely sure how this works with the many_many. Perhaps someone else could shed some light?

    [EDIT: http://doc.silverstripe.com/doku.php?id=many_many-example ]. I've created a small example here if you'd like to take a look.

  • Willr
    Avatar
    Forum Moderator
    5511 Posts

    Re: Ecommerce - Product options (sizes/colours/types...) and discounts Link to this post

    Very nice example Sean!

  • freeyland
    Avatar
    Community Member
    22 Posts

    Re: Ecommerce - Product options (sizes/colours/types...) and discounts Link to this post

    Thank you Sean. Much clearder now. Thx.

  • BeefStake
    Avatar
    23 Posts

    Re: Ecommerce - Product options (sizes/colours/types...) and discounts Link to this post

    >Very nice example Sean!
    Seconded

  • bones
    Avatar
    Community Member
    104 Posts

    Re: Ecommerce - Product options (sizes/colours/types...) and discounts Link to this post

    Sean's link no longer works. Would somebody mind reposting it for me, please.

    Thanks

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