variation

Get product variation images on Woocommerce shop page

痞子三分冷 提交于 2019-12-12 08:13:27
问题 What I essentially want to achieve is to show product variation images (particular image for each variation) on the shop page. I was successfully able to get the name of the variations using the code below (put into "content-product.php"): <?php $colourvalues = get_the_terms( $product->id, 'pa_colour'); foreach ( $colourvalues as $colourvalue ) { echo $colourvalue->name; } ?> Unfortunately there is nothing in the $colouvalues array that is the variations image url or anything related to the

How to get the Variation ID in a Woocommerce product

为君一笑 提交于 2019-12-07 04:42:31
问题 I'm trying to get in a plugin I'm writing the variation ID of products. Here's what I wrote: class mass { public function __construct() { add_action('woocommerce_product_after_variable_attributes',array($this,'thfo_mass')); } public function thfo_mass() { $id = WC_Product_Variation::get_variation_id(); //$lenght = get_post_meta($id,'_length'); //$dimensions = wc_get_dimension(24750, 'cm'); var_dump($id); } I only get an error: Deprecated: Non-static method WC_Product_Variation::get_variation