简体   繁体   English

如何在evinessmart中的购物车中获取所有产品?

[英]How to get all products in cart in virtuemart?

im a newbie of Joomla and Virtuemart. 我是Joomla和Virtuemart的新手。 i want to get/show all products in cart (product id, product image, product quantity) and i insert some code in index.php in template folder like this: 我想获取/显示购物车中的所有产品(产品ID,产品图片,产品数量),并在index.php中的模板文件夹中插入一些代码,如下所示:

foreach( $this->cart->products as $pkey =>$prow ) {
...                     
}

but it make a error on line foreach, anyone can help me i use Joomla 2.5 and Virtuemart 2 但是它在在线foreach上出错,任何人都可以帮助我,我使用Joomla 2.5和Virtuemart 2

thanks 谢谢

If you are trying to include the above code directly in the index.php It will definitely error. 如果您试图将以上代码直接包含在index.php中,则肯定会出错。 Bcoz the this pointer referenced here is Cart helper. Bcoz此处引用的此指针是Cart的助手。 That is unknown in the index.php. 那在index.php中是未知的。

If you want to insert some cart features in the index.php best method is to use the module. 如果要在index.php中插入一些购物车功能,最好的方法是使用该模块。 You can find some modules similar to the mod_cartinfo (This modules will return the cart item details.) in public_html/modules/mod_cartinfo 您可以在public_html / modules / mod_cartinfo中找到一些类似于mod_cartinfo的模块(此模块将返回购物车商品详细信息。)

you can find the module main file loads some php files that are required for the VM cart details. 您可以找到模块主文件加载了VM购物车详细信息所需的一些php文件。

if (!class_exists( 'VmModel' )) require(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_virtuemart'.DS.'helpers'.DS.'vmmodel.php');
 if (!class_exists( 'VmConfig' )) require(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart'.DS.'helpers'.DS.'config.php');
    if(!class_exists('VirtueMartCart')) require(JPATH_VM_SITE.DS.'helpers'.DS.'cart.php');
    $cart = VirtueMartCart::getCart(false);

Then use $cart istead of this->cart. 然后使用$ cart代替this-> cart。

don't try to include this code portion in your index.php.It will load every time. 不要尝试在index.php中包含此代码部分,它将每次加载。 Use module concept for achieving this. 使用模块概念来实现这一目标。 try this 尝试这个

Hope this will help you.. 希望这个能对您有所帮助..

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM