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

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.

图片转代码服务由CSDN问答提供 功能建议

我在opencart产品页面中添加了“立即购买”按钮(也将添加到购物车中)

首先我编辑了目录/视图/主题/ mytheme / template / product / product.tpl(以获取产品页面中的“立即购买”按钮)

 &lt  ;?php if($ stock ==“In Stock”){echo'&lt; input type =“button”value =“添加到购物车”id =“button-cart”class =“button-product-page”/&gt  ;';  echo“”;  echo'&lt; input type =“button”value =“立即购买”id =“button-cart-buy”class =“button-product-page”/&gt;';  } else {echo'&lt; input type =“button”value =“Out of Stock”class =“button-product-page”/&gt;';  }&gt; 
   
 
 

在此之后,在product.tpl中,我为立即购买创建了一个类似按钮的新功能(按钮 - 购买 - 购买) 函数,但我改变了json ['success'],如下所示立即购买:

  if(json ['success']){window.location ='index.php? 路线=结帐/结帐';  } 
   
 
 

当我们点击产品页面上的“立即购买”链接为( http://domain.com/Product )但是如果我们在浏览类别的产品后点击”立即购买“即 http://domain.com/MainCategory/SubCategory/Product 然后我得到网址 http://domain.com/MainCategory/SubCategory/index.php?route=checkout/checkout 。 但该产品已被添加到购物车中。

此问题主要出现在IE中,有时也会出现在Mozilla中。

我也尝试过 在common.js中复制addtoCart函数。 但仍然没有成功。

我错过了什么或需要改变..? 请帮助

致谢Jay Gilford致谢:

感谢Jay Gilford的回复。

这个答案有助于在opencart论坛解析5-6个开放主题。

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

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'); ?>'; }
    
    点赞 评论

相关推荐 更多相似问题