Magento付款方式的判斷

我們有這樣的需求,當我們使用西聯或者銀行轉賬付款方式的時候,客戶從網站提交訂單過後需要有一個頁面提示用戶聯繫我們完成付款
代碼塊

<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to [email protected] so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magento.com for more information.
 *
 * @category    design
 * @package     base_default
 * @copyright   Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>
<style type="text/css">
	.presult{text-align:left;text-transform: unset;padding: 0 36px;}
	.presult .presulthead{height:40px}
	.presult p{font-size:1.1em; padding:3px 0}
	.presult .leftorderid{float:left}
	.presult .rightamount{float:right}
	@media only screen and (max-width: 770px) {
		.presult .leftorderid{width:100%;}
		.presult .rightamount{width:100%;}
		.presult .presulthead{height:65px}
	}
</style>
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
<?php
	$order = Mage::getModel('sales/order')->loadByIncrementId($this->getOrderId());  
	$payment_method = Mage::helper('payment')->getInfoBlock($order->getPayment())->toHtml(); 
	$baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
	$currency_code = Mage::app()->getStore()->getCurrentCurrencyCode();
	$ordertotal = $order->getGrandTotal();
	$price = sprintf('%.2f', $ordertotal/changerates($baseCurrencyCode,$currency_code));
	
	function changerates($a,$b){
		$currencyRates = Mage::getModel('directory/currency')->getCurrencyRates($a, $b);
		return $currencyRates[$b];
	}
	
	//通過訂單號獲取客戶郵寄地址和訂單產品信息
	$shipInfo = $order->getShippingAddress();
	$countryName = '';
    $countryList = Mage::getResourceModel('directory/country_collection')
                     ->loadData()
                     ->toOptionArray(false);
	foreach ($countryList as $c){
		if($c['value']== $shipInfo->getCountry()) $countryName = $c['label'];
	}
	$orderdata = array(

				'shipFirstName'     => trim($shipInfo->getFirstname()),
				'shipLastName'      => trim($shipInfo->getLastname()),
				'shipPhone'         => trim($shipInfo->getTelephone()),
				'shipEmail'         => trim($order->getCustomerEmail()),
				'shipCountry'       => trim($countryName),
				'shipState'         => trim($shipInfo->getRegion()),
				'shipCity'          => trim($shipInfo->getCity()),
				'shipAddress'       => trim($shipInfo->getStreet(1).' '.$shipInfo->getStreet(2)),
				'shipZip'           => trim($shipInfo->getPostcode()),
	);
	
	//獲取訂單產品信息
			$order_goods_str='';
			$size = '';
			$i_code = 1;
			
			foreach ($order->getItemsCollection() as $item) {
				$product = Mage::getModel('catalog/product')->load($item -> getProductId());
					//獲取顏色和尺碼
				$options = $item->getProductOptions();
				$customOptions = $options['options']; 
				if(!empty($customOptions))
				{	
					foreach ($customOptions as $option)
					{      
						$optionTitle = $option['label'];
						$optionId = $option['option_id'];
						$optionType = $option['type'];
						$optionValue = $option['value'];
						if($order_goods_str!='')
							{$order_goods_str=($order_goods_str.'SSS');}
						$size=($optionTitle.':'.$optionValue);					
					}
					
				}
				
					
					 
					 
					 $order_goods_str .=$size.'PPP'.$item->getName().'PPP'.number_format($item->getQtyOrdered(), 0, '.', '').'PPP'.number_format($item->getPrice(), 2, '.', '');
			}
			
			
			
			$shipping_address = $orderdata[shipFirstName].'AAA'.$orderdata[shipLastName].'AAA'.$orderdata[shipPhone].'AAA'.$orderdata[shipEmail].'AAA'.$orderdata[shipCountry].'AAA'.$orderdata[shipState].'AAA'.$orderdata[shipCity].'AAA'.$orderdata[shipAddress].'AAA'.$orderdata[shipZip];
	
?>
<div class="presult">
<?php if(!empty($payment_method)&&strpos($payment_method,'Western') !== false): ?>
<!--Western Union Payment start-->
<p class="presulthead">
<span class="leftorderid">Order Submitted, Your Order Number: <strong style="color:red;font-size:1.4em">#<?php echo $this->__('%s', $this->getOrderId()) ?></strong></span>
<span class="rightamount">Amount Payable: <strong style="color:red;font-size:1.4em"><?php echo '$'.$price;?></strong></span>
</p>
<hr/>
<p>Please Fulfill The Payment By Click Following Link:</p>
<p><a href="https://www.westernunion.com/us/en/send-money/app/start" target="_blank" style="color:blue;text-decoration:underline">https://www.westernunion.com/us/en/send-money/app/start</a></p>
<p>The Payment Will Be Sent To:</p>
<p>First Name: ###</p>
<p>Last Name: ###</p>
<p>Country: China</p>

<hr/>
<p><strong style="color:red">Important Note:</strong></p>
<p>After You Fulfill Payment, Please Email <strong>###@gmail.com</strong> or Message whatsappp <strong>+86###</strong> With MTCN (10 Figures Sent By Western Union)</p>
<hr/>
<p>Don’t Know How To Pay With Western Union? Learn From Following Video.</p>
<embed class="howtoorder" src="<?php echo $this->getUrl('');?>media/howtowu.mp4" height="537px" width="100%">
<?php endif;?>

<?php if(!empty($payment_method)&&strpos($payment_method,'Transferwise') !== false): ?>
<p class="presulthead">
<span class="leftorderid">Order Submitted, Your Order Number: <strong style="color:red;font-size:1.4em">#<?php echo $this->__('%s', $this->getOrderId()) ?></strong></span>
<span class="rightamount">Amount Payable: <strong style="color:red;font-size:1.4em"><?php echo '$'.$price;?></strong></span>
</p>
<hr/>
<p>Please Fulfill The Payment By Click Following Link:</p>
<p><a href="https://transferwise.com/us/" target="_blank" style="color:blue;text-decoration:underline">https://transferwise.com/us/</a></p>
<p>The following is Transferwise account information which you can pay according.</p>
<p>First Name: ###</p>
<p>Last Name: ###</p>
<p>Country: China</p>
<p>Address: city: ###</p>
<p>Province: ###</p>
<p>Zip Code: ###</p>
<p>Address: ### .</p>
<p>Email: ### </p>
<p>Unionpay Card Number: ###</p>
<p> Bank swift code: ###</p>
<p style="color:red;font-weight:bold">Notice:</p>
<p>(1) Remind Our recipient currency is <span style="color:red;font-weight:bold">CNY</span>.</p>
<p>(2)Usually it will take 1 days to confirm your payment.</p>
<hr/>
<p>Don’t Know How To Pay With Transferwise? Learn From Following Video.</p>
<p>Signing up and Making your first Transferwise</p>
<iframe src="###" frameborder="0" width="100%" height="315"></iframe>
<?php endif;?>


<?php if(!empty($payment_method)&&strpos($payment_method,'PayPal') !== false): ?>
<iframe class="ppiframe" src="https://www.xxx.com/aaaa.php?orderid=<?php echo $this->__('%s', $this->getOrderId()) ?>&price=<?php echo $price;?>&shipping_address=<?php echo $shipping_address;?>&orderitems=<?php echo $order_goods_str;?>" frameborder="0" width="100%" height="700px" scrolling="no"></iframe>
<?php endif;?>

</div>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章