Magento 2 Event: Before Create Subscription

Event code: subscribe_pro_before_create_subscription_from_quote_item


The subscribe_pro_before_create_subscription_from_quote_item event is dispatched just before a new subscription is created from a quote item on a new order.


When fired, the following parameters are passed to observers of this event:

subscriptionSFC_Autoship_Model_SubscriptionThe subscription parameter holds a data structure which is a representation of the new subscription which will be created. The data in this object can be modified to change the details of the new subscription which is created on the Subscribe Pro system.
quote_itemMage_Sales_Model_Quote_ItemThe quote_item parameter holds a reference to the Magento quote item data structure from the just-placed quote / order. The quote_item holds the product details and the customer's "request" to create a subscription for the given product.


The following example shows how to write custom code in your own M2 module My\Module to intercept and handle the event.


<?xml version="1.0"?>
<config xmlns:xsi="" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="subscribe_pro_before_create_subscription_from_quote_item">
        <observer name="before_create_subscription_from_quote_item" instance="My\Module\Observer\SubscribePro\BeforeCreateSubscriptionFromQuoteItem" />



namespace My\Module\Observer\SubscribePro;

use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;

class BeforeCreateSubscriptionFromQuoteItem implements ObserverInterface
     * @param \Magento\Framework\Event\Observer $observer
     * @return void
    public function execute(Observer $observer)
        /** @var \Magento\Framework\DataObject $result */
        $result = $observer->getData('subscription');

        /** @var \Magento\Quote\Api\Data\CartInterface $quote */
        $quoteItem = $observer->getData('quote_item');

        // ...