0

I'm developing a plugin and apparently it made all the products disappear from its category.

I'm not sure what could have caused the error, since the plugin updates price based on a formula.

I share a snippet of the code.

                foreach ($catalogInventory as $valueCatalogInventory) {

                    if ($valueCatalogInventory->Sku == $valueCatalog->Sku) {
                        $sku = $valueCatalog->Sku;
                        $Checkprecio = ( $valueCatalogPrice->Price->UnitPrice == 0 ) ? 0 : $valueCatalogPrice->Price->UnitPrice;
                        $price = floatval(sanitize_text_field($Checkprecio));

                        //formula
                        $product_id = get_id_by_SKU($sku);

                        $priceBruto = round(($price*$dolar));
                        if ($priceBruto < 50000) {
                            $priceVenta = round(($price*$dolar)*1.3333*$comision);
                        }elseif($priceBruto > 50000 && $priceBruto <= 100000){
                            $priceVenta = round(($price*$dolar)*1.1905*$comision);
                        }elseif($priceBruto > 100000 && $priceBruto <= 200000){
                            $priceVenta = round(($price*$dolar)*1.1494*$comision);
                        }elseif($priceBruto > 200000 && $priceBruto <= 400000){
                            $priceVenta = round(($price*$dolar)*1.1236*$comision);
                        }elseif ($priceBruto > 400000) {
                            $priceVenta = round(($price*$dolar)*1.1111*$comision);
                        }

                       
                        
                        

                        var_dump($product_id);
                        update_post_meta($product_id, '_regular_price', $priceVenta );
                        update_post_meta($product_id, '_price', $priceVenta );


                    }

                }

dont show products in category enter image description here

any help would be appreciated.

1
  • Sorry, but WooCommerce being a third party plugin, questions about it are off topic here.
    – kero
    Jan 13 at 14:11

Your Answer

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

Browse other questions tagged or ask your own question.