Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I needed to reorder the default output of the Commerce Price Savings Formatter. Instead of the List Price, Sale Price, then Discount/Savings order I needed List Price, Discount/Savings, then Sale Price. It was suggested that I implement via preprocess and reorder. So, this is what I came up with and it works for me.
Thanks to recrit for the help!
function YOURTHEMENAME_preprocess_commerce_price_savings_formatter_formatter(&$variables) {
$temp['list'] = $variables['prices']['list'];
$temp['savings'] = $variables['prices']['savings'];
$temp['price'] = $variables['prices']['price'];
$variables['prices'] = $temp;
}
Result:
The result also shows some label overrides.
Comment | File | Size | Author |
---|---|---|---|
Screen shot 2011-12-20 at 11.37.21 AM.png | 7.71 KB | benschaaf |
Comments
Comment #0.0
benschaaf CreditAttribution: benschaaf commentedThe result image also shows some label overrides.
Comment #1
romstach CreditAttribution: romstach as a volunteer commentedHi
i applied this function in my template.php but nothing happen...
i have 7.x-1.4 version.
Thank's for your help