Php 如何在自定义模块上实现“添加到购物车”功能
我是马根托的新手。我制作了一个定制的价格计算器模块,用户在其中输入产品的高度和宽度,然后得到产品的价格。我想实现添加到购物车的功能,使高度,宽度和价格去购物车。但我不知道实现它的代码和语法 购物车功能已安装在我的项目上 这是控制器Php 如何在自定义模块上实现“添加到购物车”功能,php,magento,Php,Magento,我是马根托的新手。我制作了一个定制的价格计算器模块,用户在其中输入产品的高度和宽度,然后得到产品的价格。我想实现添加到购物车的功能,使高度,宽度和价格去购物车。但我不知道实现它的代码和语法 购物车功能已安装在我的项目上 这是控制器 class Test_Mymodule_IndexController extends Mage_Core_Controller_Front_Action { public function indexAction() {
class Test_Mymodule_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
$this->loadLayout();
$this->renderLayout();
}
public function calculateAction()
{
$request = $this->getRequest();
$printdata = $request->getPost();
if($this->getRequest()->isPost())
{
$obj = Mage::getModel("test_mymodule/results");
$show_results = $obj->showshuttersprice($printdata['width'],$printdata['height']);
}
Mage::register('data', $show_results);// In the Controller
Mage::register('width', $printdata['width']);// In the Controller
Mage::register('height', $printdata['height']);// In the Controller
$this->loadLayout();
$this->renderLayout();
}
}
这是我想要实现添加到购物车的视图
<h6 align="center">Price Results for <?php echo $width; ?> mm by <?php echo $height; ?> mm Domestic Rollershutter</h6>
<table border="1" align="center" width="100%" cellspacing="4" cellpadding="4">
<tr>
<td>Price</td> <td><?php echo "$"." ".$data; ?></td>
</tr>
</table>
<?php
}
?>
<br />
<a href ="">Add to cart</a>
mm×mm国产压路机的价格结果
价格
任何人请帮助我为了快速修复,您可以尝试创建类似于以下内容的添加到购物车url
<a href ="http://www.yourdomain.com/checkout/cart/add?product=68&qty=1">Add to cart</a>
用动态产品id替换产品值,以便它可以添加而不是
,您可以尝试:
<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart v-center" onclick="productAddToCartForm.submit(this)"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>