Shortcode that display all product attributes set for a WooCommerce product for multiple products on one custom webpage

  function, php, shortcode, woocommerce

I used the code that was offered in following topic: Shortcode that display all product attributes set for a WooCommerce product also for my web page.However, when I use the shortcode multiple times on one page refering to different product id’s, the attribute values of the first product id are also displayed in the other shortcode outputs. For example:

  • Productid A variation 1 uses Attribute value 1: "Hello"
  • Productid B variation 1 uses Attribute value 2: "Bye Bye"
  • Productid C variation 1 uses Attribute value 3: "Good day"

When I use the shortcode [display-attributes id="A"] the output is: "Hello" But when I use the shortcode also for the other productids on the same page, they also give as output "Hello", while it is expected "Bye Bye" for [display-attributes id="B"] and "Good day" for [display-attributes id="C"]

Source: Ask PHP

LEAVE A COMMENT