问题描述
我在opencart产品页面中添加了立即购买"按钮(也将添加到购物车中)
I was adding a Buy Now button in opencart product page (also add to cart will be there)
首先,我编辑了catalog/view/theme/mytheme/template/product/product.tpl(要在产品页面上获取立即购买"按钮)
First i edited catalog/view/theme/mytheme/template/product/product.tpl (to get Buy Now button in product page)
<?php if ($stock == "In Stock") { echo '<input type="button" value="Add to Cart" id="button-cart" class="button-product-page" />'; echo " "; echo '<input type="button" value="Buy Now" id="button-cart-buy" class="button-product-page" />'; } else {echo '<input type="button" value="Out Of Stock" class="button-product-page"/>'; } ?>
在此之后,在product.tpl中,我为Buy Now制作了一个新功能(button-cart-buy),类似于button-cart功能,但是我为下面的Buy Now更改了json ['success']:
And after this,in product.tpl, i made a new function (button-cart-buy) for Buy Now similar to button-cart function but i changed the json['success'] as below for Buy Now:
if (json['success']) {window.location='index.php?route=checkout/checkout'; }
当我们在产品页面上单击立即购买",链接为( http://domain.com/Product),但如果我们从以下类别浏览产品后单击立即购买",则该按钮不起作用: http://domain.com/MainCategory/SubCategory/Product ,然后我将URL设为 http: //domain.com/MainCategory/SubCategory/index.php?route=checkout/checkout .但是产品正被添加到购物车中.
Its working when we click Buy Now on product page with link as (http://domain.com/Product) but its not working if we click Buy now after browsing product from categories i.e http://domain.com/MainCategory/SubCategory/Product then i am getting url as http://domain.com/MainCategory/SubCategory/index.php?route=checkout/checkout. But the product is getting added to the Cart.
此问题主要发生在IE中,有时也发生在Mozilla中.
This issue is mainly in IE and sometimes it occurs in Mozilla also.
我还尝试了在common.js中复制addtoCart函数.但仍然无法解决.
I had also tried copying addtoCart function in common.js. But still not working out.
我是否缺少某些东西或需要更改..?请帮助
Am i missing something or need to alter..? Please help
感谢杰伊·吉尔福德(Jay Gilford):
感谢杰伊·吉尔福德(Jay Gilford)的回复.
Thanks Jay Gilford for your response.
此答案有助于解决opencart论坛中的5-6个开放线程.
This answer helps in resolving 5-6 open threads at opencart forum.
推荐答案
这是因为您没有使用绝对URL路径.如果您已在模板中获得此Javascript,则可以使用
Its because you're not using an absolute URL path. If this is in the template you've got this Javascript, you can just use
if (json['success']) {window.location='<?php echo $this->url->link('checkout/checkout', '', 'SSL'); ?>'; }
这篇关于Opencart:在Opencart产品页面中添加“立即购买"按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!