Trying to add some extra code - by Pavlos Pavlidis

This topic has 5 replies, 2 voices, and was last updated 3 years, 11 months ago ago by Rose Tyler

  • Avatar: Pavlos Pavlidis
    Pavlos Pavlidis
    Participant
    December 24, 2020 at 00:33

    hello, i am trying to add the below simple attribute list on the single product page
    on the functions.php in the child theme. but does not do anything.

    //show attributes after summary in product single view
    add_action('woocommerce_single_product_summary', function() {
    	
    	global $product;
    	echo $product->list_attributes();
    }, 25);
    4 Answers
    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    December 24, 2020 at 08:57

    Hello,

    According to your choice to use the Single Product Builder there is fully different structure of actions. Most of them are coming from XStore theme/XStore Core. So that default woocommerce actions will not work normally, because if they would then there could not be such customizable options to use for the builder.
    If you need to add your custom actions for single product while you are using builder, please use next actions for that :

    etheme_woocommerce_template_single_title
    etheme_woocommerce_template_single_rating
    etheme_woocommerce_template_single_price
    etheme_woocommerce_template_single_excerpt
    etheme_woocommerce_template_single_add_to_cart
    etheme_woocommerce_template_single_meta
    etheme_woocommerce_template_woocommerce_breadcrumb
    woocommerce_share
    etheme_woocommerce_template_single_sharing
    etheme_woocommerce_show_product_images
    etheme_woocommerce_output_product_data_tabs
    etheme_woocommerce_output_upsell_products
    etheme_woocommerce_output_cross_sells_products
    etheme_woocommerce_output_related_products
    etheme_product_single_size_guide
    etheme_product_single_size_guide
    etheme_product_single_button
    etheme_product_single_widget_area_01
    etheme_product_single_custom_html_01
    etheme_product_single_custom_html_02
    etheme_product_single_custom_html_03
    etheme_product_single_additional_custom_block
    etheme_product_single_product_description
    etheme_product_single_wishlist
    etheme_product_single_compare

    You can use it as you did with default ones. Please, add code to your child-theme/functions.php

    Example:

    add_action('etheme_woocommerce_template_single_title', function() {
    global $product;
    echo $product->get_id();
    });

    Regards

    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    December 24, 2020 at 09:11

    By the way your code is deprecated since Woocommerce v.3.0

    You should use smth like next code:

    add_action('etheme_woocommerce_template_single_title', function() {
    	global $product;
    	wc_display_product_attributes($product);
    }, 25);

    Regards

    Avatar: Pavlos Pavlidis
    Pavlos Pavlidis
    Participant
    December 29, 2020 at 23:53

    thank you very much !
    🙂

    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    December 30, 2020 at 08:03

    You’re welcome!

    Would you mind to rate our product: 
    https://prnt.sc/d256m6
    https://themeforest.net/downloads
    That would be much appreciated 🙂

    Regards

  • Viewing 5 results - 1 through 5 (of 5 total)

The issue related to '‘trying to add some extra code’' has been successfully resolved, and the topic is now closed for further responses

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.