1

I'm looking to extend Craft Commerce with a custom Purchasable.

I'd like to implement this using a module if possible.

I've implemented the base class for my new Purchasable and that's all good.

What I'm wondering is can I add this new Purchasable type to the Commerce cpNavItem list?

My new Purchasable extends the base Purchasable class as follows: class Donation extends Purchasable and I'm registering using the following Events:

Event::on(Purchasables::class, Purchasables::EVENT_REGISTER_PURCHASABLE_ELEMENT_TYPES, function(RegisterComponentTypesEvent $event) {
            $event->types[] = CustomPurchasable::class;
        });

Event::on(Elements::class, Elements::EVENT_REGISTER_ELEMENT_TYPES, function(RegisterComponentTypesEvent $e) {
            $e->types[] = CustomPurchasable::class;
        });

I know that if I go the plugin route I can register a new control panel nav section but I'd like to avoid that if possible and keep this new Purchasable inside of the Commmerce nav section.

kind regards,

piaras

Your Answer

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

Browse other questions tagged or ask your own question.