Set a fixed price when a subscription is created


By default, when Subscribe Pro places a reorder back to Magento for a subscription, the price is calculated at that time based on the current price set in the store, including any special price rules and discounts. As of version 1.3.2.4, our Subscribe Pro extension now allows a fixed price field to be set for subscriptions, so that new orders will use that price instead of the price set in Magento.

This price will need to be set by adding some custom code to hook onto the sfc_autoship_before_create_subscription_from_quote_item event.

config.xml

<config>
    <global>
        <events>
            <sfc_autoship_before_create_subscription_from_quote_item>
                <observers>
                    <my_module_sfc_autoship_before_create_subscription_from_quote_item>
                        <class>mymodule/observer</class>
                        <method>onBeforeCreateSubscriptionFromQuoteItem</method>
                    </my_module_sfc_autoship_before_create_subscription_from_quote_item>
                </observers>
            </sfc_autoship_before_create_subscription_from_quote_item>
        </events>
    </global>
</config>

Observer.php:onBeforeCreateSubscriptionFromQuoteItem()

public function onBeforeCreateSubscriptionFromQuoteItem(Varien_Event_Observer $obs)
{
    // Get data from $observer
    /** @var SFC_Autoship_Model_Subscription $subscription */
    $subscription = $observer->getData('subscription');
    /** @var Mage_Sales_Model_Quote_Item $quoteItem */
    $quoteItem = $observer->getData('quote_item');
    // Set date on subscription
    $subscription->setData('use_fixed_price', 1);
    $subscription->setData('fixed_price', $quoteItem->getPrice());
}