wordpress 在产品页面上为 woocommerce 添加其他按钮

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26225696/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 11:01:42  来源:igfitidea点击:

add additional button on product page for woocommerce

wordpresswoocommerceproductwoothemesvariations

提问by user3715275

I have spent the majority of the day trying to figure out how to adjust the single product page using woocommerce.

我花了一天的大部分时间试图弄清楚如何使用 woocommerce 调整单个产品页面。

I would like to add a custom button next to the "Add to cart" button that would be a custom link that says "Next". I am working on an invitation website where there are numerous components to an invitation, so after a user adds a product to their cart, I want there to be an option that says "Next" so they can go ahead and customize the next piece of the invitation. (I will have custom fields for each). The next button won't be on all products, and the link will be different for each. I don't think this is the best way to do it, but don't have another solution right now.

我想在“添加到购物车”按钮旁边添加一个自定义按钮,该按钮将是一个显示“下一步”的自定义链接。我正在一个邀请网站上工作,其中有许多邀请的组件,因此在用户将产品添加到他们的购物车后,我希望有一个显示“下一步”的选项,以便他们可以继续自定义下一个邀请。(我将为每个自定义字段)。下一个按钮不会出现在所有产品上,每个产品的链接都不同。我不认为这是最好的方法,但现在没有其他解决方案。

I also was researching bundles products or "composite products" - however, composite products are all on one page and I will need to add variations for each for quantities of 25/50/75/100 etc...

我也在研究捆绑产品或“复合产品”——但是,复合产品都在一页上,我需要为每个产品添加 25/50/75/100 等数量的变化......

See link below: http://blisspaperboutique.com/product/retro-romance-wedding-invitation-template/

请参阅以下链接:http: //blisspaperboutique.com/product/retro-romance-wedding-invitation-template/

Could someone please provide any feedback or suggestions!! PLEASEEE. Thank you

有人可以提供任何反馈或建议!!拜托了。谢谢

Here is a site that is doing something similar to what I am trying to do: http://www.weddingpaperdivas.com/product/16445/signature_white_wedding_invitations_enchanting_forever.html#color/04

这是一个正在做类似于我想要做的事情的网站:http: //www.weddingpaperdivas.com/product/16445/signature_white_wedding_invitations_enchanting_forever.html#color/04

回答by Prashant Kanse

Add below code in your theme's function.php file.

在主题的 function.php 文件中添加以下代码。

add_action( 'woocommerce_single_product_summary', 'my_extra_button_on_product_page', 30 );

function my_extra_button_on_product_page() {
  global $product;
  echo '<a href="URL">Extra Button</a>';
}

Cheers!!!

干杯!!!