如何从结帐运输方法部分访问自定义输入值并在catalog\model\shipping\flat.php中使用它
到目前为止,在catalog\view\theme\default\template\checkout\checkout.tpl中我已经改变了:
data: $('#shipping-method input[type=\'radio\']:checked, #shipping-method textarea'),至:
data: $('#shipping-method input[type=\'hidden\'], #shipping-method input[type=\'radio\']:checked, #shipping-method textarea'),所以现在我猜自定义值是通过Ajax发布的,但是如何在上面提到的flat.php中访问它呢?
在catalog\controller\checkout\shipping.php中
$this->session->data['shipping_method'] = $this->session->data['shipping_methods'][$shipping[0]]['quote'][$shipping[1]];我已经添加了
$custom = $this->session->data['custom'];但是不知道从哪里开始,所以$custom变量将在flat.php中可用。
发布于 2013-06-13 22:42:17
欢迎使用StackOverflow!
我猜$this->session->data['custom']会返回null并生成一个Undefined index通知,因为您没有为这个索引设置任何值(或者您只是没有发布代码?)。
在shipping.php中,而不是您的代码行
$custom = $this->session->data['custom'];做
$this->session->data['custom_value'] = $this->request->post['shipping_method']['custom'];(我假设隐藏字段的名称为custom,并以shipping_method数组的形式通过AJAX发送)
现在我们已经设置了会话的值,您可以在flat.php中执行以下操作
$custom = $this->session->data['custom_value'];现在,自定义隐藏值也出现在flat.php中。
https://stackoverflow.com/questions/17089179
复制相似问题