【问题标题】:How do i insert product name and its information into redirec.phtml in magento?如何在 magento 中将产品名称及其信息插入 redirec.phtml?
【发布时间】:2013-07-28 11:33:49
【问题描述】:

支付网关给了我这个代码,它是用来集成到支付页面的:

Please replace these items with the appropriate data:
• with the ID auto-generated by Gateway for the merchant.
• with the input field of the transaction amount.
• with the input field of the order id.
• with the input field of the product name.
• with the input field of the customer email.

这里有示例:

<input type="hidden" name="mercId" value="">
<input type="hidden" name="currCode" value="">
<input type="hidden" name="amt" value="">
<input type="hidden" name="orderId" value="">
<input type="hidden" name="prod" value="">
<input type="hidden" name="email" value="">

然后我尝试将其合并到正在工作的redirect.phtml中。

<?php
// Retrieve order
$_order = new Mage_Sales_Model_Order();
$orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
$_order->loadByIncrementId($orderId);
?>
<form name="mygatewayform" method="post" action="https://sample.com/MerchantServices/MakePayment.aspx">
<input type="hidden" name="orderId" value="<?php echo $orderId; ?>">
<input type="hidden" name="amt" value="<?php echo $_order->getBaseGrandTotal(); ?>">
<input type="hidden" name="mercId" value="05430">
<input type="hidden" name="prod" value="BLACKBERRY BLACK SKIN WHITE">  
<input type="hidden" name="email" value="<?php echo $_order->getCustomerEmail(); ?>">    
</form>
<script type="text/javascript">
document.mygatewayform.submit();
</script>

但每次我尝试插入客户以编程方式购买的产品名称时&lt;?php echo $productname = $item-&gt;getName(); ?&gt; 不会将我重定向到支付网关页面它只会停在 www.domain.com/index.php/mygateway/付款/重定向/。这是我尝试过的,它没有再次重定向。

<?php
// Retrieve order
$_order = new Mage_Sales_Model_Order();
$orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
$_order->loadByIncrementId($orderId);
?>
<form name="mygatewayform" method="post" action="https://sample.com/MerchantServices/MakePayment.aspx">
    <input type="hidden" name="orderId" value="<?php echo $orderId; ?>">
    <input type="hidden" name="amt" value="<?php echo $_order->getBaseGrandTotal(); ?>">
        <input type="hidden" name="mercId" value="05430">
    <input type="hidden" name="prod" value="<?php echo $productname = $item->getName(); ?>">  
    <input type="hidden" name="email" value="<?php echo $_order->getCustomerEmail(); ?>">    
</form>
<script type="text/javascript">
document.mygatewayform.submit();
</script>

请告诉我我做错了什么,或者更确切地说如何将产品名称和信息插入或将其调用到redirect.phtml页面中?

谢谢

【问题讨论】:

  • 我确信product name 不是真正的产品名称。网关提供商对您销售的产品不感兴趣。简单想一想,如果您的购物车中有多个产品,您会怎么做?
  • 感谢您的评论,但每次客户从我们的网站下订单时,我们都需要包含将显示在最终支付网关页面上的产品名称,这就是为什么它有必要包括它。每次我通过手动插入默认产品名称来测试运行它时,它都会重定向到支付网关方式,例如docs.google.com/file/d/0B0ffR5TX4SpueUlsWTBMYXZ2MHc/…
  • 你在使用谷歌结账吗?
  • 我想你用的是 V-Money,对吧?
  • Abiodun,如果您有网关提供商 API 文档,请与我分享。我应该看看他们想要什么。因为,您尝试在表单中插入产品名称,但您没有想到它们是否是购物车中的多个产品!

标签: magento


【解决方案1】:

我不确定这段代码是否能解决您的问题,但如果我没记错的话,getName() 函数不起作用是因为 $item

首先,您应该加载购物车中可用的商品。

$items = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();

// then loop on items
foreach ($items as $item) {
    echo $item->getName().'<br />';
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多