• Resolved resepu

    (@resepu)


    I want to display product title and some of the attribute names in the product description.
    For example, I want a product description like:

    What is new in [product-title]? [product-title] is one of the best products in [attribute-brand] category on our website. We see that with the introduction of [attribute-color] version of [product-title], [product-title] gets attention. It has [attribute-lens] and is about [attribute-size].

    As you can see, I want to display only the name of the product and attribute name. It would be great if I didn’t have to enter the product id because I will replace these shortcodes into my product descriptions. There are more than 1.5k products.

    I cannot find enough information about this on the web. Is there anyone know how I can do that?

    Thank you very much in advance

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Vova

    (@gn_themes)

    Hi @resepu,

    the plugin does not offer such shortcodes. But, you can use the following shortcodes to display post fields and meta field values. These shortcodes do not require post IDs.

    [su_post field="post_title" post_type="post"]
    
    [su_meta key="my_custom_field"]
    Thread Starter resepu

    (@resepu)

    Helloo @gn_themes,
    I found how to use product-title shortcode.

    Do you have any idea how I can create shortcodes according to product attributes?

    Plugin Author Vova

    (@gn_themes)

    If product attributes are stored as custom fields, you can use the [su_meta] shortcode.

    Thread Starter resepu

    (@resepu)

    Unfortunately they are not and it’d be very difficult for me if I created custom fiedlds for products one by one because there are more than 1k products on my website.

    Actually I find a way to show a certain attribute on frontend with the following code:
    <?php echo $colors = array_shift( wc_get_product_terms( $product->id, 'pa_brand', array( 'fields' => 'names' ) ) ); ?>

    But I couldn’t create a shortcode with this.
    If you can help me with creating a shortcode with this code, I’d be super happy.

    Plugin Author Vova

    (@gn_themes)

    The following code will create [product-colors] shortcode:

    add_shortcode( 'product-colors', function( $atts, $content = null ) {
      return 'something';
    } );

    You can replace return 'something'; with your own code. Please note, your code must return a string. This echo $colors = array_shift( wc_get_product_terms( ... WILL NOT return a string, it will return an array, so you must adjust it before adding.

    Thread Starter resepu

    (@resepu)

    Thank you for your help.
    But I have very little knowledge about PHP and I don’t know how adjust that array as a string.
    As I understood, what I want to get can only be done with that array because it needs to check the attribute of the product.
    So it is not possible. :/

    Plugin Author Vova

    (@gn_themes)

    Everything is possible with WordPress. Unfortunately, I’m not familiar enough with WooCommerce to help you.

    You could contact someone who knows how WC work.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Product Title and Product Attribute Name’ is closed to new replies.