本文整理汇总了PHP中xPDO::save方法的典型用法代码示例。如果您正苦于以下问题:PHP xPDO::save方法的具体用法?PHP xPDO::save怎么用?PHP xPDO::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xPDO
的用法示例。
在下文中一共展示了xPDO::save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: calculateOrderPrice
/**
* calculateOrderPrice
* Calculate order price
*
* @access public
* @param xPDO $order The xPDO order object
* @return array The order amounts
*/
public function calculateOrderPrice($order, $savePrices=true) {
if ($order == null) {
return false;
}
$orderBasket = $order->get('basket');
$shop = $order->getOne('Shop');
$modx =& $this->modx;
$amounts = array();
$amounts['totalProductsPriceIn'] = 0;
$amounts['totalProductsPriceEx'] = 0;
$amounts['totalShippingPriceEx'] = 0;
$amounts['totalWeight'] = 0;
$highestTax = null;
$this->fireEvent('vcEventCalculateOrder', 'before', array(
'vcAction' => 'process',
'shop' => $shop,
'order' => $order
));
if (is_array($orderBasket) && sizeof($orderBasket) > 0) {
foreach($orderBasket as $product) {
$productObject = $this->modx->getObject('vcProduct', $product['id']);
if ($productObject == null) {
continue;
}
// Get the tax category
$taxCategory = $productObject->getOne('TaxCategory');
if ($highestTax == null) {
$highestTax = $taxCategory;
} elseif ($highestTax->get('pricechange') < $taxCategory->get('pricechange')) {
$highestTax = $taxCategory;
}
$productPrice = $this->calculateProductPrice($productObject, true);
$shippingPrice = $productObject->get('shippingprice');
$amounts['totalProductsPriceIn'] += ($productPrice['in'] * $product['quantity']);
$amounts['totalProductsPriceEx'] += ($productPrice['ex'] * $product['quantity']);
$amounts['totalShippingPriceEx'] += ($shippingPrice * $product['quantity']);
$amounts['totalWeight'] += ($productObject->get('weight') * $product['quantity']);
}
// Format totals
$amounts['totalProductsPriceIn'] = number_format($amounts['totalProductsPriceIn'], 2, '.', '');
$amounts['totalProductsPriceEx'] = number_format($amounts['totalProductsPriceEx'], 2, '.', '');
$amounts['totalShippingPriceEx'] = number_format($amounts['totalShippingPriceEx'], 2, '.', '');
// Calculate shipping taxes
$taxAmount = ($amounts['totalShippingPriceEx'] / 100) * $highestTax->get('pricechange');
if ((int) $this->getShopSetting('calculateShippingTaxes', $shop->get('id')) == 1) {
$amounts['totalShippingPriceIn'] = number_format(($amounts['totalShippingPriceEx'] + $taxAmount), 2, '.', '');
} else {
$amounts['totalShippingPriceIn'] = $amounts['totalShippingPriceEx'];
}
// Get payment method costs
if ($order->get('shippingid') != 0) {
$shippingModule = $order->getOne('ShippingModule');
if ($shippingModule != null) {
// Get the main controller file
$controller = $this->config['corePath'].'modules/shipping/'.$shippingModule->get('controller');
if (is_file($controller)) {
$vcAction = 'calculateOrderAmount';
$returnValue = include($controller);
// Merge current shipping data with shipping data returned from module
if (isset($returnValue) && is_array($returnValue)) {
if (!is_array($order->get('shippingdata'))) {
$order->set('shippingdata', array());
}
$order->set('shippingdata', array_merge($order->get('shippingdata'), $returnValue));
}
unset($returnValue);
if (isset($module)) {
unset($module);
}
}
}
}
// Get payment method costs
if ($order->get('paymentid') != 0) {
$paymentModule = $order->getOne('PaymentModule');
if ($paymentModule != null) {
$amounts['paymentCostsEx'] = 0;
//.........这里部分代码省略.........