Friday, 15 April 2011

php - How to display variations in the Shop page Woocommerce -


I want to display differences with prices instead of regular prices on the first page, not an item page.

Now: $ 10-100

I need it: - $ 10 Rent - $ 100 Buy

I want to show prices for variations I use this function in Add Prices to Php

  // variations add_filter ('woocommerce_variation_option_name', 'Enter code here' '' '' '' '' '. Function display_price_in_variation_option_name ($ word) {global $ wpdb, $ Product; $ result = $ wpdb- & gt; get_col ("steal {$ wpdb-> prefix} rules where name = '$ word' '); $ Term_slug = (empty ($ result)) $ $ Results [0]: $ word; $ Query = "SELECT postmeta.post_id AS product_id FROM {$ wpdb- & gt; prefix} postmeta AS postmeta LEFT JOIN {$ wpdb- & gt; prefix} .ID = postmeta.post_id) like 'attribute_%' and postmeta.meta_value = '$ term_slug' as WHERE postmeta.meta_key and above Ifts ($ origin & gt; 0); $ (value); $ _product = New WC_Product_Variation ($ variation_id [0]); // This is the price where you can actually customize how the price is displayed in the return word '(' .woocommerce_price ($ _product- & gt; Get_price ()). '' '; } Return word; }  

But how can I request variations in the loop of the shop page? I try to use get_available_variations (); But it does not work for me


No comments:

Post a Comment