Fork me on GitHub

You may want to sell things other than generic products within your store. You may need additional features and functionality for these products. You might want to sell something that already exists as a different kind of DataObject in your site.

Here are a few options:

  • Customise the Product class(es) using decorators, or modifying core code.
  • Subclass Product to create your own type of product.
  • Turn a DataObject into something Buyable.

If you want to sell things that a visitor can choose customisations of, you should consider make use of the product variations system. Alternatively, the module supports creating your own customisations.

In most cases you will need to customise or create your own order items. These record the relationship between a product/buyable and an order.

class MyOrderItem extends OrderItem{

    static $db = array(
        'MyField' => 'Varchar'

    static $has_one = array(
        'Buyable' => 'MyProduct'



The concept of something being buyable was introduced to allow things other than Products to be included in the cart. The Buyable interface enforces a few methods that are needed for objects to be added to the shopping cart. Product and ProductVariation are both examples of models implementing the Buyable interface. You can see another example at the bottom of the shop/tests/CustomProductTest.php file.

To make your DataObject buyable:

  • Create/choose the class of what you want to become buyable. It must extend DataObject at some point.
  • Add 'implements Buyable'
  • Introduce the functions required by the interface.
  • Extend OrderItem as something like MyBuyable_OrderItem.
  • Specify the buyable relationship on your MyBuyable_OrderItem.
  • Create an array of required_fields on the MyBuyable_OrderItem, which tells the system which fields are unique, and should be matched when interacting with the shopping cart.
  • You will also need to implement TableTitle if you want your custom item to show up in the cart.
  • Implement Link if you want the item to link somewhere, such as viewing the buyable on your site.

Completely custom products - every time you add one to cart, it doesn't attempt to combine with existing matches. Match on the OrderItemId for quantity changes.