How can we do fields linked to products that the user can personalises when buying that product, ie writes in a custom gift message and picks an option of gif wrapped with additional cost.

Our client would have a few of these on each product some with costs and some free of charge.

We have looks at variants but seem we would have to make a new product/variant for each combination which would be a lot not variants, is there another way?

1 Answer 1


To add additional information about a product when adding to cart, you can use the options param to submit any data you wish along with the product you are adding to cart. You can see documentation on this here: https://craftcommerce.com/docs/add-to-cart#line-item-options-and-notes

As for modifying the price of the product based on those options; this is not possible by default in Craft Commerce, although we have provided a way that a plugin can achieve this.

There are 2 possible solutions:

1) Write a plugin that provides a Purchasable. A purchasable is a Craft Element, which your customers could build or edit on the front-end, and then add it to the cart. This is the more advanced path. You would need to know how to create a Craft Element, allow front end users to create and edit them, then make the element a purchasable. Documentation on Purchasables here: https://craftcommerce.com/docs/purchasables

2) Submit line item option data, but write a plugin that uses the onPopulateLineItem event to modify the price of the line item based on the option data submitted. It would look something like this:

craft()->on('commerce_lineItems.onPopulateLineItem', function($event){

    $purchasable= $event->params['purchasable'];
    $lineItem = $event->params['lineItem'];

    if(isset($lineItem->options['giftWrapped']) && $lineItem->options['giftWrapped'] == 'yes'){
        $lineItem->price = $purchasable->getPrice() + 10; // gift wrap is 10 dollars
        $lineItem->saleAmount = 0;


The original price would still show in the product listing, but the option submitted when adding to cart would change the price of the line item when in the cart.

The 2 methods above allow you to have configurable prices of products.

  • Thanks so much Luke, do you know if there are any plans to add something like this as it seem like something that could be baked in? Thanks again for you help.
    – Green17
    Nov 2, 2016 at 15:07
  • 1
    Is this still true for Craft Commerce 3? Not possible to change a lineItem's price based on selected options except by writing a plugin?
    – Andreas
    Apr 7, 2021 at 15:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.