• Resolved sgarmash777

    (@sgarmash777)


    Hi,
    My orders page does not display product attributes, only variable attributes. How to display a simple attribute, maybe someone has encountered such a problem?

    Standard function $product->get_attribute (); only works if the product does not have a variable product, but I need a variable product and its attribute.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello @sgarmash777,

    I believe what you are looking for can be found in the code, here:

    https://docs.woocommerce.com/wc-apidocs/source-class-WC_Product_Variation.html#112-124

    It shows the following code:

    
      /**
         * Get variation attribute values. Keys are prefixed with attribute_, as stored.
         *
         * @return array of attributes and their values for this variation
         */
        public function get_variation_attributes() {
            $attributes           = $this->get_attributes();
            $variation_attributes = array();
            foreach ( $attributes as $key => $value ) {
                $variation_attributes[ 'attribute_' . $key ] = $value;
            }
            return $variation_attributes;
        }
    

    Is this what you are looking for? I am not completely familiar with PHP but this shows code referring to “Get variations attribute values.” in the code comment. I found this code from the following page:

    https://docs.woocommerce.com/wc-apidocs/class-WC_Product_Variation.html

    I found it near the top of the page, it’s the 7th entry of the page. I hope this helps! If you have any further questions please let me know.

    AJ a11n

    (@amandasjackson)

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘orders page does not display product attributes’ is closed to new replies.