Last active
November 12, 2018 13:17
-
-
Save denvit/a99db3ceebdae5d7953fdab26132aad9 to your computer and use it in GitHub Desktop.
Drupal 7 - Hook alters stock display message. Formatter for Stock must be set as "Unformatted" on Product > Manage display.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Implements hook_commerce_product_reference_default_delta_alter(). | |
| */ | |
| function test_module_commerce_product_reference_default_delta_alter(&$delta, $products) { | |
| $test = 123; | |
| foreach ($products as $product) { | |
| if ($product->commerce_stock['und'][0]['value'] > 0){ | |
| $products[1]->commerce_stock['und'][0]['value'] = "On stock"; | |
| }else { | |
| $product->commerce_stock['und'][0]['value'] = "Out of stock"; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment