Forum Replies Created

Viewing 16 replies (of 16 total)
  • Just wanted to share this with you as i was looking at the same exact problem.

    Add this to your /theme/woocommerce/single-products/price.php

    //get the regular price of the product, but of a simple product
    $regular_price = get_post_meta( get_the_ID(), '_regular_price', true);
    $sale_price = get_post_meta( get_the_ID(), '_price', true);
    
    if ($regular_price >= $sale_price){
    $available_variations = $product->get_available_variations();
    
    $variation_id=$available_variations[0]['variation_id']; 
    $variable_product1= new WC_Product_Variation( $variation_id );
    $regular_price = $variable_product1 ->sale_price;
    }
    if ($sale_price >= $regular_price){
    $available_variations = $product->get_available_variations();
    
    $variation_id=$available_variations[0]['variation_id']; 
    $variable_product1= new WC_Product_Variation( $variation_id );
    $regular_price = $variable_product1 ->regular_price;
    }

    Then find <meta itemprop="price" content="<?php echo esc_attr( $product->get_price() ); ?>" /> and replace it with <meta itemprop="price" content="<?php echo esc_attr( $regular_price ); ?>" />

    That should now work for single, and variable products.

Viewing 16 replies (of 16 total)