Customizing the Product Discount Text


There are 3 options for changing the way the text about the subscription discount is shown::

Use Magento's Translation System to translate that text Override our getSubscriptionPriceText() method, and use your own custom logic Build your string directly in the theme / template files

1. Use Magento's Translation System to translate that next.

Magento has a translation system that lets you replace certain words with other text. This will apply to all instances of the text.

2. Override our getSubscriptionPriceText() method, and use your own custom logic

The second method for customizing the discount text is to override our helper class SFC_Autoship_Helper_Subscription, found in the app/code/local/SFC/Autoship/Helper/Subscription file. This helper is referenced in Magento as:

$subscriptionHelper = Mage::helper('autoship/subscription'); First, create a new module for your added code. Then in your config.xml file, specify that your method should override Subscribe Pro's helper.

<helpers>
    <autoship>
        <rewrite>
            <subscription>Your_Module_Autoship_Helper_Subscription</subscription>
        </rewrite>
    </autoship>
</helpers>

Finally, your new helper class and add the following method, which will override the one provided by Subscribe Pro.

/**
* Return the price for purchasing the product with a subscription, formatted and with text indicating the discount amount
*
* @param SFC_Autoship_Model_Platform_Product $platformProduct Subscription profile for product
* @param Mage_Catalog_Model_Product $product Mage product object
* @return string Price of product, formatted and with text indicating the discount
*/
public function getSubscriptionPriceText(SFC_Autoship_Model_Platform_Product $platformProduct, Mage_Catalog_Model_Product $product, $qty = 1)

By doing it this way, the change is applied across all templates.

3. Build your string directly in the template files

Alternately, you can modify each template file directly, giving you more control over how it is shown depending on which page the customer is viewing. Here are some of the theme files in which the $this->getDiscountText() method shows up:

app\design\frontend\base\default\template\autoship\product\subscribe.phtml app\design\frontend\base\default\template\autoship\product\view\type\grouped\subscribe.phtml app\design\frontend\base\default\template\autoship\mysubscriptions\subscription\product_info.phtml

You may replace that function call with your own text, using the following variables to access the appropriate data regarding the product discount amount and whether the it is a percentage or a fixed amount.

/** @var SFC_Autoship_Model_Platform_Product $platformProduct */
$platformProduct = $this->getPlatformProduct();
$discountAmount = $platformProduct->getData('discount');
$isDiscountPercentageOrFixed = $platformProduct->getData('is_discount_percentage');