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

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

<p>There are 2 possible solutions:</p>

<p>1) Write a plugin that provides a <code>Purchasable</code>. 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: <a href="https://craftcommerce.com/docs/purchasables" rel="nofollow noreferrer">https://craftcommerce.com/docs/purchasables</a></p>

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

<pre><code>craft()-&gt;on('commerce_lineItems.onPopulateLineItem', function($event){

    $purchasable= $event-&gt;params['purchasable'];
    $lineItem = $event-&gt;params['lineItem'];

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

});
</code></pre>

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

<p>The 2 methods above allow you to have configurable prices of products.</p>

CC BY-SA 3.0
2016-11-02T15:07:56.403Z
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
CC BY-SA 4.0
2021-04-07T15:10:59.997Z
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
CC BY-SA 3.0
2016-11-02T08:58:45.883Z
2016-11-02T08:58:45.883Z
Luke Holder
<p>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.</p>

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

<p>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?</p>

<plugin-craftcommerce>
Per item ie gift wrapped with additional cost in Craft Commerce?
# Per item ie gift wrapped with additional cost in Craft Commerce?

(Asked by: username_0 on 2016-10-31)

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?

**Tags:** plugin-craftcommerce

---

## 1 answers

### Answer by username_1 on 2016-11-02. Score: 3 | Accepted answer

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.

> **Comments:**
> **username_0**: 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.  
> **username_2**: 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?  

---

