WooCommerce: How to display fields from the “Product Add-ons” extension?

后端 未结 2 2150
无人共我
无人共我 2021-02-14 12:17

I\'m using the [Product Add-ons][1] extension for WooCommerce, which allows custom fields for products. This automatically displays on the single product template.

By s

2条回答
  •  爱一瞬间的悲伤
    2021-02-14 13:07

    It's impossible to give you an exact copy-paste solution without access to the code, but it should be possible to attach the same function that is being hooked.

    The hook that adds this to the single product page probably looks like this:

    add_action( 'woocommerce_single_product_summary', array($this, 'woocommerce_product_add_ons_something'));
    

    To attach this action to the achive template as well you should probably be able to do something like this:

    add_action( 'woocommerce_after_shop_loop_item_title', array('WC_Product_Add_On', 'woocommerce_product_add_ons_something')); 
    

    WC_Product_Add_On is the class name of the plguin and needs to be changed to match the class that has the function/method in the action. Put this code in the functions.php file in your theme.

    See if it works. If not, give me more information and I can expand my answer.

提交回复
热议问题