Commerce Conditional Module for checking SKU's in rules
I'm in the process of finishing up a module for checking for the existence of a particular sku/skus in a product referenced by a line item. I would like to publish this so the whole community can use it. Essentially it's a module built by Prince Manfred called Commerce Conditional. Due to the fact that i'm using the conditional on the action 'calculating a shipping rate' it doesn't have the entities i need in scope. How do I bring it in scope? I have the commerce_line_item but the scope is only the shipping line item. Enclosed is the check that the rules condition does. Please help me increase the scope to the product line items and the skus of the products. Thanks :)
<?php
function commerce_sku_condition_has_sku($line_item, $sku_id) {
if (!empty($line_item)) {
$wrapper = entity_metadata_wrapper('commerce_line_item', $line_item);
$sku_ids = $wrapper->commerce_product->sku->raw();
if (!empty($sku_ids)) {
if (is_array($sku_ids)) {
foreach ($sku_ids as $sku_id_line_ids) {
if ($sku_id_line_ids == $sku_id) {
return TRUE;
}
}
}
}
}
return FALSE;
}
?>