是否有可能获得外部使用的magento cart摘要(total和#items)?

时间:2011-12-02 09:34:35

标签: java magento soap

我还要使用magento和外部(基于java springframework的)品牌网站。

用户将看到“购买”按钮。 我还想让用户在每个外部页面的标题中看到购物车信息摘要(总数+购物车中的商品数量)。 结账过程将照常进行magento。

Magento提供肥皂api。

当用户想要结帐并付款时,我无法理解如何处理从我的网站切换回magento。

情景1

  1. 用户浏览我的java网站并最终点击“购买”按钮(在这种情况下,这是简单的REST链接到magento实例http://yourdomain.com/checkout/cart/add/product/ {ID} ... shoppingCartId是在magento的网站上创建的)
  2. 通过服务器端java调用magento的web服务(cart.list和cart.total i presume)检索购物车摘要 - > 问。我应该使用哪个shoppingCartId
  3. 一个简单的链接将用户直接发送到magento的网站进入购物车页面
  4. 情景2:

    1. 用户浏览我的java网站并最终点击“购买”按钮(这是对magento的web服务cart_product.add的服务器端java调用; shoppingCartId是通过Web服务创建并存储到java会话中)
    2. 通过服务器端java调用magento的web服务(cart.list和cart.total,我认为)检索购物车摘要,从java会话中检索shoppingCartId
    3. 一个简单的链接将用户直接发送到magento的网站购物车页面,shoppingCartId存储到java会话中,我想新的购物车将显示给用户: Q.是否有指向特定购物车的REST链接(即使用shoppingCartId作为参数)?

1 个答案:

答案 0 :(得分:1)

您可以使用以下代码在外部使用magento数据(例如购物车):

<?php
/**
 * @author      MagePsycho <info@magepsycho.com>
 * @website     http://www.magepsycho.com
 * @category    using Magento Externally
 */
$mageFilename = 'app/Mage.php';
require_once $mageFilename;
#Mage::setIsDeveloperMode(true);
#ini_set('display_errors', 1);
umask(0);
Mage::app();
Mage::getSingleton('core/session', array('name'=>'frontend'));

#Get total items and total quantity in cart
$totalItems = Mage::getModel('checkout/cart')->getQuote()->getItemsCount();
$totalQuantity = Mage::getModel('checkout/cart')->getQuote()->getItemsQty();

#Get subtotal and grand total price of cart
$subTotal = Mage::getModel('checkout/cart')->getQuote()->getSubtotal();
$grandTotal = Mage::getModel('checkout/cart')->getQuote()->getGrandTotal();

希望这会对你有所帮助。 干杯!!