3

I am looking for a solution that would allow me to sell events tickets within Craft. I'm am currently making a prototype with Craft Commerce plugin for this project, but I am already facing a major problem.

When creating a new product, I can set a ticket price + a total number of tickets available at this price. When using variants, I can define multiple tickets + a total of available tickets under each price. But it does not seems possible to synchronize a total number of available tickets with different price options (full price and other at reduced fare).

How can I do ? Is it possible to set the total number of tickets available outside of variants, such as the variants would be only used to set the price ?

1 Answer 1

2

Craft Commerce support has answered to my question :

Currently Craft Commerce can not have a stock counter that covers more than one variant. The default product+variant system is not designed for tickets. We hope to see a ticket 'Purchasable' plugin in the future. You can request this feature here.

If you have some plugin experience, you could get around this issue you described with a plugin that updates the stock of other variants when someone purchases a variant using the onOrderVariant event. You would likely need to know the relationships between SKUs for the different variants within your plugin, and deduct the stock from the related variants like so:

craft()->db->createCommand()->update('commerce_variants',
  ['stock' => new \CDbExpression('stock - :qty', [':qty' => $theQty ])],
  'id = :variantId',
  [':variantId' => $variantId]);

Check out the Stock Notifier plugin as it matches closely to the events you would need to use.

Your Answer

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

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