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 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测