我正在和Magento合作。我只需要一个按钮,将产品添加到购物车,然后去检查页面,不要查看购物车。意味着我想直接订购注册用户。我正在 PORTO Magento主题工作 我通过创建cartController.php函数 addAction (app / code / core / checkout / controllers /)到myaddAction()来尝试它。
在JS下面添加结束 view.phtml(app / design / frontend / your package / your template / template / catalog / product / view.phtml)
productAddToCartForm.submitmy = function(button, url){
replaceURL = url.replace("add/","myadd/");
if(this.validator) {
var nv = Validation.methods;
delete Validation.methods['required-entry'];
delete Validation.methods['validate-one-required'];
delete Validation.methods['validate-one-required-by-name'];
// Remove custom datetime validators
for (var methodName in Validation.methods) {
if (methodName.match(/^validate-datetime-.*/i)) {
delete Validation.methods[methodName];
}
}
if (this.validator.validate()) {
if (url) {
this.form.action = replaceURL;
}
this.form.submit();
}
Object.extend(Validation.methods, nv);
}
}.bind(productAddToCartForm);
并将更改操作更改为购物车控制器中的myaddAction并更改了
$this->_goBack();
to
$this->_redirect('checkout/onepage');
return;
但我得到一个错误未定义的功能, productAddToCartForm.submitmy
请希望有人帮忙。
答案 0 :(得分:0)
我会在add_to_cart_after
上创建一个观察者,然后在此处设置重定向。简单的事情:
$response = $observer->getResponse();
$url = Mage::helper('checkout/url')->getCheckoutUrl();
$response->setRedirect($url);
die();