Forum Replies Created

Viewing 1 replies (of 1 total)
  • What I’ve noticed is that the calculations differ depending on whether they’re done on the product page or in the cart. On the product page, the variation is used to determine stock or backorder, while in the cart, the parent product is used, which is why the dates come out differently.

    So I’ve decided to unify this. I’m not sure if this is the right approach, but here’s what I’ve done:

    function edw_display_cart_item( $item_data, $cart_item ) {
    $product_id = $cart_item['product_id'];
    $variation_id = isset($cart_item['variation_id']) && $cart_item['variation_id'] ? $cart_item['variation_id'] : null;

    //Se define el id correspondiente
    $effective_product_id = $variation_id ? $variation_id : $product_id;

    $date = $this->edw_show_message($effective_product_id, true);


    y luego en edw_show_message:



    function edw_show_message($productParam = false, $separed = false){
    .....

    if(isset($_POST['type']) and $_POST['type'] == 'variation') {
    $product_id = $product->get_parent_id();
    }else{
    if($product) {
    $product_id = $product->get_id();
    }else{
    $product_id = false;
    }
    }
    //Se define el product_id correspondiente para los datos de las fechas
    $product_id = $product->is_type('variation') ? $product->get_parent_id() : $product->get_id();
Viewing 1 replies (of 1 total)