本文整理汇总了PHP中VirtueMartCart::getST方法的典型用法代码示例。如果您正苦于以下问题:PHP VirtueMartCart::getST方法的具体用法?PHP VirtueMartCart::getST怎么用?PHP VirtueMartCart::getST使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VirtueMartCart
的用法示例。
在下文中一共展示了VirtueMartCart::getST方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkConditions
/**
* @param \VirtueMartCart $cart
* @param int $method
* @param array $cart_prices
* @return bool
*/
protected function checkConditions ($cart, $method, $cart_prices) {
static $result = array();
if($cart->STsameAsBT == 0){
$type = ($cart->ST == 0 ) ? 'BT' : 'ST';
}else{
$type = 'BT';
}
$address = $cart -> getST();
if(!is_array($address)) $address = array();
if(isset($cart_prices['salesPrice'])){
$hashSalesPrice = $cart_prices['salesPrice'];
} else {
$hashSalesPrice = '';
}
if(empty($address['virtuemart_country_id'])) $address['virtuemart_country_id'] = 0;
if(empty($address['zip'])) $address['zip'] = 0;
$hash = $method->virtuemart_shipmentmethod_id.$type.$address['virtuemart_country_id'].'_'.$address['zip'].'_'.$hashSalesPrice;
if(isset($result[$hash])){
return $result[$hash];
}
$this->convert ($method);
$orderWeight = $this->getOrderWeight ($cart, $method->weight_unit);
$countries = array();
if (!empty($method->countries)) {
if (!is_array ($method->countries)) {
$countries[0] = $method->countries;
} else {
$countries = $method->countries;
}
}
$weight_cond = $this->testRange($orderWeight,$method,'weight_start','weight_stop','weight');
$nbproducts_cond = $this->_nbproductsCond ($cart, $method);
if(isset($cart_prices['salesPrice'])){
$orderamount_cond = $this->testRange($cart_prices['salesPrice'],$method,'orderamount_start','orderamount_stop','order amount');
} else {
$orderamount_cond = FALSE;
}
$userFieldsModel =VmModel::getModel('Userfields');
if ($userFieldsModel->fieldPublished('zip', $type)){
if (!isset($address['zip'])) {
$address['zip'] = '';
}
$zip_cond = $this->testRange($address['zip'],$method,'zip_start','zip_stop','zip');
} else {
$zip_cond = true;
}
if ($userFieldsModel->fieldPublished('virtuemart_country_id', $type)){
if (!isset($address['virtuemart_country_id'])) {
$address['virtuemart_country_id'] = 0;
}
if (in_array ($address['virtuemart_country_id'], $countries) || count ($countries) == 0) {
//vmdebug('checkConditions '.$method->shipment_name.' fit ',$weight_cond,(int)$zip_cond,$nbproducts_cond,$orderamount_cond);
vmdebug('shipmentmethod '.$method->shipment_name.' = TRUE for variable virtuemart_country_id = '.$address['virtuemart_country_id'].', Reason: Countries in rule '.implode($countries,', ').' or none set');
$country_cond = true;
}
else{
vmdebug('shipmentmethod '.$method->shipment_name.' = FALSE for variable virtuemart_country_id = '.$address['virtuemart_country_id'].', Reason: Country '.implode($countries,', ').' does not fit');
$country_cond = false;
}
} else {
vmdebug('shipmentmethod '.$method->shipment_name.' = TRUE for variable virtuemart_country_id, Reason: no boundary conditions set');
$country_cond = true;
}
$allconditions = (int) $weight_cond + (int)$zip_cond + (int)$nbproducts_cond + (int)$orderamount_cond + (int)$country_cond;
if($allconditions === 5){
$result[$hash] = true;
return TRUE;
} else {
$result[$hash] = false;
//vmdebug('checkConditions '.$method->shipment_name.' does not fit ',(int)$weight_cond,(int)$zip_cond,(int)$nbproducts_cond,(int)$orderamount_cond,(int)$country_cond);
return FALSE;
}
$result[$hash] = false;
return FALSE;
}
示例2: checkConditions
/**
* Check if the payment conditions are fulfilled for this payment method
* @param VirtueMartCart $cart
* @param int $activeMethod
* @param array $cart_prices
* @return bool
*/
protected function checkConditions($cart, $activeMethod, $cart_prices)
{
//Check method publication start
if ($activeMethod->publishup) {
$nowDate = JFactory::getDate();
$publish_up = JFactory::getDate($activeMethod->publishup);
if ($publish_up->toUnix() > $nowDate->toUnix()) {
return FALSE;
}
}
if ($activeMethod->publishdown) {
$nowDate = JFactory::getDate();
$publish_down = JFactory::getDate($activeMethod->publishdown);
if ($publish_down->toUnix() <= $nowDate->toUnix()) {
return FALSE;
}
}
$this->convert_condition_amount($activeMethod);
$address = $cart->getST();
$amount = $this->getCartAmount($cart_prices);
$amount_cond = ($amount >= $activeMethod->min_amount and $amount <= $activeMethod->max_amount or $activeMethod->min_amount <= $amount and $activeMethod->max_amount == 0);
$countries = array();
if (!empty($activeMethod->countries)) {
if (!is_array($activeMethod->countries)) {
$countries[0] = $activeMethod->countries;
} else {
$countries = $activeMethod->countries;
}
}
// probably did not gave his BT:ST address
if (!is_array($address)) {
$address = array();
$address['virtuemart_country_id'] = 0;
}
if (!isset($address['virtuemart_country_id'])) {
$address['virtuemart_country_id'] = 0;
}
if (in_array($address['virtuemart_country_id'], $countries) || count($countries) == 0) {
if ($amount_cond) {
return TRUE;
}
}
return FALSE;
}
示例3: checkConditions
/**
* @param \VirtueMartCart $cart
* @param int $method
* @param array $cart_prices
* @return bool
*/
protected function checkConditions($cart, $method, $cart_prices)
{
static $result = array();
if ($cart->STsameAsBT == 0) {
$type = $cart->ST == 0 ? 'BT' : 'ST';
} else {
$type = 'BT';
}
$address = $cart->getST();
if (!is_array($address)) {
$address = array();
}
if (isset($cart_prices['salesPrice'])) {
$hashSalesPrice = $cart_prices['salesPrice'];
} else {
$hashSalesPrice = '';
}
if (empty($address['virtuemart_country_id'])) {
$address['virtuemart_country_id'] = 0;
}
if (empty($address['zip'])) {
$address['zip'] = 0;
}
$hash = $method->virtuemart_shipmentmethod_id . $type . $address['virtuemart_country_id'] . '_' . $address['zip'] . '_' . $hashSalesPrice;
if (isset($result[$hash])) {
return $result[$hash];
}
$this->convert($method);
$orderWeight = $this->getOrderWeight($cart, $method->weight_unit);
$countries = array();
if (!empty($method->countries)) {
if (!is_array($method->countries)) {
$countries[0] = $method->countries;
} else {
$countries = $method->countries;
}
}
$weight_cond = $this->testRange($orderWeight, $method, 'weight_start', 'weight_stop', 'weight');
$nbproducts_cond = $this->_nbproductsCond($cart, $method);
if (isset($cart_prices['salesPrice'])) {
$orderamount_cond = $this->testRange($cart_prices['salesPrice'], $method, 'orderamount_start', 'orderamount_stop', 'order amount');
} else {
$orderamount_cond = FALSE;
}
$userFieldsModel = VmModel::getModel('Userfields');
if ($userFieldsModel->fieldPublished('zip', $type)) {
if (!isset($address['zip'])) {
$address['zip'] = '';
}
$zip_cond = $this->testRange($address['zip'], $method, 'zip_start', 'zip_stop', 'zip');
} else {
$zip_cond = true;
}
if ($userFieldsModel->fieldPublished('virtuemart_country_id', $type)) {
if (!isset($address['virtuemart_country_id'])) {
$address['virtuemart_country_id'] = 0;
}
if (in_array($address['virtuemart_country_id'], $countries) || count($countries) == 0) {
//vmdebug('checkConditions '.$method->shipment_name.' fit ',$weight_cond,(int)$zip_cond,$nbproducts_cond,$orderamount_cond);
vmdebug('shipmentmethod ' . $method->shipment_name . ' = TRUE for variable virtuemart_country_id = ' . $address['virtuemart_country_id'] . ', Reason: Countries in rule ' . implode($countries, ', ') . ' or none set');
$country_cond = true;
} else {
vmdebug('shipmentmethod ' . $method->shipment_name . ' = FALSE for variable virtuemart_country_id = ' . $address['virtuemart_country_id'] . ', Reason: Country ' . implode($countries, ', ') . ' does not fit');
$country_cond = false;
}
} else {
vmdebug('shipmentmethod ' . $method->shipment_name . ' = TRUE for variable virtuemart_country_id, Reason: no boundary conditions set');
$country_cond = true;
}
$cat_cond = true;
if ($method->categories or $method->blocking_categories) {
if ($method->categories) {
$cat_cond = false;
}
//vmdebug('hmm, my value',$method);
//if at least one product is in a certain category, display this shipment
if (!is_array($method->categories)) {
$method->categories = array($method->categories);
}
if (!is_array($method->blocking_categories)) {
$method->blocking_categories = array($method->blocking_categories);
}
//Gather used cats
foreach ($cart->products as $product) {
if (array_intersect($product->categories, $method->categories)) {
$cat_cond = true;
//break;
}
if (array_intersect($product->categories, $method->blocking_categories)) {
$cat_cond = false;
break;
}
}
//if all products in a certain category, display the shipment
//.........这里部分代码省略.........