简体   繁体   English

Magento的。 将可配置产品的“添加到购物车”按钮更改为“预购”按钮

[英]Magento. Change “Add to cart” button to “Pre-order” button for configurable products

Thank you in advance for any help (I first post my question here , but there is no reply for several days). 预先感谢您的帮助(我先在这里发表问题,但几天都没有答复)。

In Magento, I am looking to change "Add to cart" button to "Pre-order" button for configurable products which inventory qty is set to 0. 在Magento中,我希望将库存数量设置为0的可配置产品的“添加到购物车”按钮更改为“预购”按钮。

Using this tutorial , I managed to accomplish what I am looking for but as it seems this solution works for simple products only, not for configurable ones (or I missed something) 通过使用本教程 ,我设法完成了所需的工作,但是看来该解决方案仅适用于简单的产品,不适用于可配置的产品(或者我错过了一些东西)

I looked this post, where a person says that SCP Simple Configurable Product extension made by Organic Internet solved his issue. 我看了这篇文章,有人说由Organic Internet制造的SCP简单可配置产品扩展解决了他的问题。 I am not sure how it helped him. 我不确定这对他有什么帮助。 I have this extension installed on my site. 我的网站上安装了此扩展程序。 It seems that there is no option for changing button from "add to cart" to "pre-order" or anything like that. 似乎没有选择将按钮从“添加到购物车”更改为“预订”之类的选项。 Perhaps I miss something. 也许我想念一些东西。

Can anyone give me a hand in solving this issue or point me in the right direction? 谁能帮我解决这个问题或为我指明正确的方向?

The tutorial has a php condition which is looking for the Qty value. 本教程有一个php条件,它正在寻找Qty值。 The problem is, with configurable products, you need to load the associated simple products in order to pull the Qty values. 问题是,对于可配置产品,您需要加载关联的简单产品才能提取“数量”值。

Suggestion: have you tried using issaleable? 建议:您是否尝试过使用issale? This would only show the "Pre-Order" button if the product is NOT saleable. 如果该产品不可销售,则只会显示“预购”按钮。

<?php if( $_product->isSaleable() ): echo $addtocart; else: echo $preorder; endif; ?>

If you simple want ALL your configurable products to have the "Pre-Order" button regardless of inventory, one solution is to modify this Qty condition to only check if its a Configurable product or not instead. 如果您简单地希望所有可配置产品都具有“ Pre-Order”按钮,而与库存无关,则一种解决方案是修改此“数量”条件,以仅检查其是否为可配置产品。 One way is to change all occurrences of this: 一种方法是更改​​所有这种情况:

<?php if($_product->getStockItem()->getQty()>0): echo $addtocart; else: echo $preorder; endif; ?>

to this: 对此:

<?php if( $_product->getTypeId() == 'configurable' ): echo $preorder; else: echo $addtocart; endif; ?>

Here's an example of loading the associated simple products, in order to get the Qty values. 这是加载相关联的简单产品以获取数量值的示例。 This may not be needed since its more complex. 由于它比较复杂,因此可能不需要。

foreach ($_product->getTypeInstance(true)->getUsedProducts ( null, $_product) as $simple) {
     Mage::getModel('cataloginventory/stock_item')->loadByProduct($simple)->getQty();
 }

在pordut / list.phtml中,尝试检查产品类型,如图所示

<?php if( $_product->getTypeId() == 'configurable' ): ?>

First of all go to app/design/frontend/[your-package]/[your-theme]/template/catalog/product/view/addtocart.phtml. 首先转到app / design / frontend / [您的程序包] / [您的主题] /template/catalog/product/view/addtocart.phtml。 There you can code like: 您可以在其中编写如下代码:

<?php if($_product ->getTypeId() == 'configurable'): ?>
//Do your part

All the best 祝一切顺利

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 “添加到购物车”按钮在可配置产品中显示,但在magento中的简单产品中不显示 - Add to cart button showing in configurable products but not in simple products in magento Magento:无法将产品添加到具有可配置产品的购物车 - Magento: Cannot Add products To Cart With Configurable Products Magento目录视图,显示“添加到购物车”和预购按钮(到目前为止的代码) - Magento Catalog View, Displaying Add To Cart & Pre-Order Buttons (Code So Far Inside) Magento分组产品的单独“添加到购物车”按钮 - Individual “Add To Cart” Button for Magento Grouped Products 具有单独“添加到购物车”按钮的分组产品 (Magento) - Grouped Products with Individual “Add To Cart” Button (Magento) 如何在可配置产品页面上添加自定义空购物车按钮:Magento - How to add a custom empty cart button on configurable product page:Magento 如何更改“添加到购物车”按钮以查看“产品列表”部分中的按钮 - how to change add to cart button to view button in list of products section WooCommerce 预购产品的条件标签 - Conditional tag for WooCommerce Pre-Order Products 在Woocommerce商店页面中更改用于简单产品的购物车按钮 - Change add-to-cart button for simple products in Woocommerce shop page WooCommerce - 更改 40 英镑或更多产品的“添加到购物车”按钮文本 - WooCommerce - Change Add to Cart button text for products £40 or more
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM