1

I'm building a template page for my own woocommerce theme.

[ISSUE:] While I call the function woocommerce_template_single_add_to_cart it show the section which contain the html output of the variations' dropwown and the descriptions/prices related on current selected variation. All right, it do the output correctly inside the proper div element, like this:

<div class="single_variation_wrap">
    <div class="woocommerce-variation single_variation" style="">
        <div class="woocommerce-variation-description">
            <p>Option 1 description</p>
        </div>
    <div class="woocommerce-variation-price">
    etc....

I need to separate this section from the dropdown's html output, so I wrote the code to show only the dropdown and it work, but I'm unable to show again the dynamic description and price! Which is the correct function to call in order to show just the variation's description and its price?

Thanks in advance!

2
  • You can use result, returned from wc_get_product for showing required data. $_product = wc_get_product( $product_id );
    – BlueSuiter
    Dec 7 '17 at 5:43
  • 1
    SOLVED: I found the template part which call the code about price variations. It is inside: /mytheme/woocommerce/single-product/add-to-cart/variation.php
    – Giangel84
    Dec 8 '17 at 0:41
-2

$_product = wc_get_product( $product_id );

This displays price: $_product->get_price()

This displays description: $_product->get_variation_description()

1
  • This doesn't get either the price or description, but throws errors for calling on a member function.
    – Nathan
    Jul 11 '19 at 23:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.