dounieqi6959 2014-04-22 12:31
浏览 342
已采纳

Opencart:在Opencart产品页面中添加“立即购买”按钮

I was adding a Buy Now button in opencart product page (also add to cart will be there)

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"/>'; } ?>

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'; }

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.

This issue is mainly in IE and sometimes it occurs in Mozilla also.

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

A word for thanks for Jay Gilford:

Thanks Jay Gilford for your response.

This answer helps in resolving 5-6 open threads at opencart forum.

  • 写回答

1条回答 默认 最新

  • dpzp5127 2014-04-22 12:59
    关注

    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'); ?>'; }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥50 成都蓉城足球俱乐部小程序抢票