Home Forums WoodMart support forum Showing other product data in simple product page

Showing other product data in simple product page

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #272979

    yosnap
    Participant

    Hello,
    How can I join the Extra product info in the Product info, as showed in the ss. I would like to keep the Product info format and just merge with the other product data. Can you help me?

    Thank you

    Attachments:
    You must be logged in to view attached files.
    #273014

    dido76bg
    Participant

    Hi!

    You should create them as attributes and check them not to show on product page (or if you want you can leave them). Then you shoul create e custom function in your child theme functions.php file.

    #273040

    Hello,


    @yosnap
    First of all thanks for choosing our Theme, we are glad to be you in the WoodMart WordPress family :).

    I saw the screenshot you attached.

    You need to create them as attributes as well then they will be displayed in the table as you added above.


    @dido76bg
    Thanks for your involvement.

    Best Regards

    #273077

    yosnap
    Participant

    Thank you for answering,

    I’ve already edited the functions file and created a custom function, but I don’t know how to show that data in the table. I create a PHP code to show that as block bellow the product info

    #273090

    Hello,


    @dido76bg
    Please reply to the @yosnap question and help him to achieve the required results as you suggested to him earlier.

    Regards.
    Xtemos Studios

    #273109

    dido76bg
    Participant

    Hi!

    If you want it to be easier you can name your attribures to start with pinfo_ – for product info section and einfo_ – for extra info sections so you can call the with foreach.

    It is a more complex solution than adding attributes to an array but it is all up to you.

    For example:

    function mycustom_productpage_attributesinfo(){
    global $product;
    $attributes = $product->get_attributes();
    if ( ! $attributes ) {
    return;
    }
    $outputpi = ‘<div class=”custom-product-attributes-show”>’;
    /*product info*/
    $outputpi .= ‘<div class=”label”>Product Info</div>’;
    foreach ( $attributes as $attribute ) {
    $attribute_slug = str_replace( ‘pa_’, ”, $attribute->get_name() );
    if ( $attribute->get_variation() ) { //skip variations
    continue;
    }
    $name = $attribute->get_name();
    if ( $attribute->is_taxonomy() && strstr($attribute_slug, ‘pinfo_’) ) {
    $terms = wp_get_post_terms( $product->get_id(), $name, ‘all’ );
    $tax = $terms[0]->taxonomy;
    $tax_object = get_taxonomy($tax);
    if ( isset ( $tax_object->labels->singular_name ) ) {
    $tax_label = $tax_object->labels->singular_name;
    } elseif ( isset( $tax_object->label ) ) {
    $tax_label = $tax_object->label;
    if ( 0 === strpos( $tax_label, ‘Product ‘ ) ) {
    $tax_label = substr( $tax_label, 8 );
    }
    }
    $outputpi .= ‘<div class=”‘ . esc_attr( $name ) . ‘”>’;
    $outputpi .= ‘<span class=”attribute-label”>’ . esc_html( $tax_label ) . ‘: </span> ‘;
    $tax_terms = array();
    foreach ( $terms as $term ) {
    $single_term = esc_html( $term->name );
    array_push( $tax_terms, $single_term );
    }
    $outputpi .= ‘<span class=”attribute-value”>’ . implode(‘, ‘, $tax_terms) . ‘</span></div>’;
    }
    }
    /*end product info*/
    /*extra info*/
    $outputpi .= ‘<div class=”label”>Extra Info</div>’;
    foreach ( $attributes as $attribute ) {
    $attribute_slug = str_replace( ‘pa_’, ”, $attribute->get_name() );
    if ( $attribute->get_variation() ) { //skip variations
    continue;
    }
    $name = $attribute->get_name();
    if ( $attribute->is_taxonomy() && strstr($attribute_slug, ‘einfo_’) ) {
    $terms = wp_get_post_terms( $product->get_id(), $name, ‘all’ );
    $tax = $terms[0]->taxonomy;
    $tax_object = get_taxonomy($tax);
    if ( isset ( $tax_object->labels->singular_name ) ) {
    $tax_label = $tax_object->labels->singular_name;
    } elseif ( isset( $tax_object->label ) ) {
    $tax_label = $tax_object->label;
    if ( 0 === strpos( $tax_label, ‘Product ‘ ) ) {
    $tax_label = substr( $tax_label, 8 );
    }
    }
    $outputpi .= ‘<div class=”‘ . esc_attr( $name ) . ‘”>’;
    $outputpi .= ‘<span class=”attribute-label”>’ . esc_html( $tax_label ) . ‘: </span> ‘;
    $tax_terms = array();
    foreach ( $terms as $term ) {
    $single_term = esc_html( $term->name );
    array_push( $tax_terms, $single_term );
    }
    $outputpi .= ‘<span class=”attribute-value”>’ . implode(‘, ‘, $tax_terms) . ‘</span></div>’;
    }
    }
    /*end extra info*/

    $outputpi .= ‘</div>’;

    echo $outputpi;
    }
    add_action( ‘woocommerce_single_product_summary’, ‘mycustom_productpage_attributesinfo’, 25 ); /*you ca add your own hook*/

    #273150

    yosnap
    Participant

    Sorry but I’ve got confused because I’m not familiar with code. I would like to use it with Elementor

    Is there anyway to remove the Product info section?

    Thank you

    #273209

    Hello,


    @dido76bg
    You both can continue your discussion until the issue is solved and we won’t interrupt you.


    @yosnap
    When the issue is resolved then please let us know so that I can close the topic.

    Best Regards

    #273215

    dido76bg
    Participant

    Hi!
    Elementor has nothing to do with the code.
    I am a little bit confused because the code that I have shared is as you asked in your picture.
    Now you don’t want the product info.
    Please be more specific.
    Do you want to remove the product info tab, or you want to remove Product info from my code?

Viewing 9 posts - 1 through 9 (of 9 total)