My client wishes to sell artwork online. They're all one-off pieces and once one is sold, it should not be available to purchase thereafter.

However, the artwork needs to have an option to be framed which would increase the price.

I can't see how this can be achieved with Variants as each variant has their own stock level.


Worked it out!

Putting this in a custom module should do the trick..., obviously changing the price modifier and option name to your needs.

            function(LineItemEvent $event) {
                // @var LineItem $lineItem
                $lineItem = $event->lineItem;
                // @var bool $isNew
                $isNew = $event->isNew;

                if (isset($lineItem->options['giftWrapped']) && $lineItem->options['giftWrapped'] == 'yes') {
                    $lineItem->price += 20;
  • 1
    Yeh that's the way I'd do it, too. Feel free to set this as the accepted answer if you'd like. Aug 14 '20 at 14:37
  • Hi @GlennJ; i tried your code, i need something similar. but in my cart it decreases the price with 20, but then makes a sale and reduces the price again with 20. So in the end the price stays the same. Did something change in between or do i have to add something special here? i use the template "giftWrapped" checkbox. thanks for your help!
    – Henrik
    Aug 3 at 19:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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