[英]How disable redirection when add item to cart with SyliusCartBundle in Symfony2?
I'm already implement the basic of SyliusCartBundle ( http://docs.sylius.org/en/latest/bundles/SyliusCartBundle/installation.html ) 我已经实现了SyliusCartBundle的基础( http://docs.sylius.org/en/latest/bundles/SyliusCartBundle/installation.html )
but the problem is the method to add item to a cart, because the only way that I know is with 但问题是将商品添加到购物车的方法,因为我知道的唯一方法是
<a href="{{ path('sylius_cart_item_add', {'productId': product.id}) }}">Add product to cart</a>
acording to http://docs.sylius.org/en/latest/bundles/SyliusCartBundle/actions.html 根据http://docs.sylius.org/en/latest/bundles/SyliusCartBundle/actions.html
and I want to add a item without redirect the webpage. 并且我想添加一个项目而不重定向网页。
sorry if is too basic but I only start with symfony 4 day ago. 对不起,如果太基础了,但我仅在4天前开始使用symfony。
Just like @zizoujal say is with ajax. 就像@zizoujal所说的是用ajax。 But when I ask I was a beginner in MVC and I dont undestand the method.
但是当我问我是MVC的初学者时,我并不理解这种方法。
The solution is: 解决方案是:
Finally I dont use Symfony2 (SyliusCartBundle) but with a little more experience in MCV I can undestand and I implment my own action (in cakephp). 最终,我不使用Symfony2(SyliusCartBundle),但对MCV有了更多的经验,我可以理解并实现自己的行动(在cakephp中)。
Not the best way to do it but it may help you: 这不是最好的方法,但是它可以帮助您:
Sylius/Bundle/CartBundle/Controller/CartItemController:addAction
. Sylius/Bundle/CartBundle/Controller/CartItemController:addAction
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.