lundi 26 octobre 2015

Custom Options(image or file) in WooCommerce

I want to show Custom Option's image or file instead of image or file name in order view page in admin and order page in my account in front end of woocommerce.

I have used this hook:

woocommerce_add_order_item_meta()

and add data in order meta but only image name is shown but not the image.

this is my function:

function order_item_meta($item_id,$values) {




        if ( ! empty( $values['options'] ) ) {

            foreach ( $values['options'] as $options ) {


                $name = ucwords(str_replace('_', ' ', $options['name']));

                if ( $options['price'] > 0 ) {

                    $name .= ' (' . woocommerce_price($this->get_product_addition_options_price( $options['price'] ) ) . ')';
                }

                if ( $options['option_price'] > 0 ) {

                    $name .= ' (' . woocommerce_price($this->get_product_addition_options_price( $options['option_price'] ) ) . ')';
                }

                  wc_add_order_item_meta( $item_id, $name, $options['value'] );


            }
        }



    }

This code add all options correctly, but it show image name of an image instead of showing image itself, but i need to show image.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire