• Resolved kullar

    (@kullar)


    I have product with variations and one variation has wrong price. I have set that all products have 10% discount but in 1 variantion has wrong price(-88%) shown, but when I open product then price is shown correctly.

    
    $variations = $product->get_available_variations();
    
    foreach ($variations as $variation){
     $variation_id       = $variation['variation_id'];		
     $product_variation  = new WC_Product_Variation($variation_id);
     $price              = $product_variation->get_price();
    }
    
    • This topic was modified 4 years, 11 months ago by kullar.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 16 through 18 (of 18 total)
  • Thread Starter kullar

    (@kullar)

    I got it solved(I started to edit plugin files and printed variables out), but I think that there still exists some overlap between variables ID and products id’s if they match or something like that. It is not logical that this line difference affects price.

    How I got sovled:

    
    $id = get_the_ID();
    $product = wc_get_product($id);
    $price = $product->get_price(); //If I move this price line inside not variable then prices are correct and also discounts.
    
    if (!$product->is_type('variable')) {
     //move price line to here and everything is correct
     //$price = $product->get_price();
    } else {
     $variations = $product->get_available_variations();
     foreach ($variations as $variation){	
       $product_variation  = new WC_Product_Variation($variation['variation_id']);
       $price              = $product_variation->get_price();
     }
    }
    
    Plugin Support ijas

    (@ijasacodez)

    Sorry for the late response and thanks for the code. We will check the same and may be can integrate the code on our plugin.

    Plugin Support ijas

    (@ijasacodez)

    I’m closing this thread. Please feel free to open a new thread if you have any further questions.

Viewing 3 replies - 16 through 18 (of 18 total)
  • The topic ‘1 variation price is wrong’ is closed to new replies.