当前位置: 首页>>代码示例>>PHP>>正文


PHP xPDO::get方法代码示例

本文整理汇总了PHP中xPDO::get方法的典型用法代码示例。如果您正苦于以下问题:PHP xPDO::get方法的具体用法?PHP xPDO::get怎么用?PHP xPDO::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xPDO的用法示例。


在下文中一共展示了xPDO::get方法的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;
//.........这里部分代码省略.........
开发者ID:rtripault,项目名称:VisionCart,代码行数:101,代码来源:visioncart.class.php


注:本文中的xPDO::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。