Created
January 14, 2014 18:03
-
-
Save jasonruyle/8422776 to your computer and use it in GitHub Desktop.
Revisions
-
jasonruyle created this gist
Jan 14, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ <?php // Use the code inside rule conditions with a Custom PHP code // FIELD_MACHINE_NAME example: field_product_free_shipping global $user; $commerce_order = commerce_cart_order_load($user->uid); $line_items = $commerce_order->commerce_line_items['und']; foreach ($line_items as $lid) { $line_item = commerce_line_item_load($lid['line_item_id']); if ( isset($line_item->commerce_product)) { $pid = $line_item->commerce_product['und'][0]['product_id']; $product = commerce_product_load($pid); $FIELD_MACHINE_NAME = render($product->FIELD_MACHINE_NAME['und'][0]['value']); if ($FIELD_MACHINE_NAME == '1') { return TRUE; } } } return FALSE;