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

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 给我一个openharmony跑通webrtc实现视频会议的简单demo项目,sdk为12
  • ¥15 vb6.0使用jmail接收smtp邮件并另存附件到D盘
  • ¥30 vb net 使用 sendMessage 如何输入鼠标坐标
  • ¥15 关于freesurfer使用freeview可视化的问题
  • ¥100 谁能在荣耀自带系统MagicOS版本下,隐藏手机桌面图标?
  • ¥15 求SC-LIWC词典!
  • ¥20 有关esp8266连接阿里云
  • ¥15 C# 调用Bartender打印机打印
  • ¥15 我这个代码哪里有问题 acm 平台上显示错误 90%,我自己运行好像没什么问题
  • ¥50 C#编程中使用printDocument类实现文字排版打印问题