template.php:
----------------------------------------------------------------------------------------------
function yourthemename_in_object($val, $obj){
if($val == ""){
watchdog("payment_conditions", "in_object expects parameter 1 must not empty");
return false;
}
if(!is_object($obj)){
$obj = (object)$obj;
}
foreach($obj as $key => $value){
if(!is_object($value) && !is_array($value)){
if($value == $val){
return true;
}
}else{
return yourthemename_in_object($val, $value);
}
}
return false;
}
--------------------------------------------------------------------------------------------
In Ubercart settings:
Payment methods/Shipping quotes -> condition -> add -> Execute custom PHP code
code:
---------------------------------------------------------------------------------------------
$shippable = true;
foreach($order->products as $product) {
$nid=$product->nid;
$results = db_query('SELECT tid FROM {taxonomy_index} WHERE nid = :nid', array(':nid' => $node->nid));
$terms = array();
foreach ($results as $result) {
$terms[] = ($result->tid);
}
$val = 2586 // needle
if(yourthemename_in_object($val, $terms)) {
$shippable = false;
break;
}
}
return $shippable;
-----------------------------------------------------------------------------------------------
Brak komentarzy:
Prześlij komentarz