• Hello. I have using two things:

    apply_filters( 'tinvwl_allow_add_parent_variable_product', true )

    And i have added code prevent add variables, only parent.

    /**
    * Force adding parent variable product to wishlist
    *
    * @param array $data wishlist product array.
    *
    * @return array
    */
    function tinvwl_force_parent_variable_product( $data ) {

    if ( 'variable' === $data['product_type'] ) {
    $data['product_variation'] = 0;
    }

    return $data;
    }

    add_filter( 'tinvwl_addtowishlist_prepare', 'tinvwl_force_parent_variable_product' );

    /**
    * Remove extra meta when force adding parent variable product to wishlist
    *
    * @param array $data wishlist product array.
    *
    * @return array
    */
    function tinvwl_force_parent_variable_product_meta( $data ) {

    if ( isset( $data['product_id'] ) ) {
    $product = wc_get_product( absint( $data['product_id'] ) );
    if ( $product && 'variable' === $product->get_type() ) {
    return array();
    }
    }

    return $data;
    }

    add_filter( 'tinvwl_addtowishlist_prepare_form', 'tinvwl_force_parent_variable_product_meta' );

    If you add product to wishlist its okey, heart is red, but if you select variation, heart is white again, you can select again. How to make if product added to wishlist when you select variations hearth have to be still red (selected).

Viewing 1 replies (of 1 total)
  • Thread Starter dowista

    (@dowista)

    I found solution in public.min.js file you need to change i.variation_id to 0.

    Find:

    if(e.attr("data-tinv-wl-productvariation",i.variation_id),e.length&&e.attr("data-tinv-wl-list")){var s=JSON.parse(e.attr("data-tinv-wl-list")),l=!1,o="1"==window.tinvwl_add_to_wishlist.simple_flow;for(var a in s)s[a].hasOwnProperty("in")&&Array.isArray(s[a].in)&&-1<(s[a].in||[]).indexOf(i.variation_id)&&(l=!0);e.toggleClass("tinvwl-product-in-list",l).toggleClass("tinvwl-product-make-remove",l&&o).attr("data-tinv-wl-action",l&&o?"remove":"addto")}

    Change to:

    if(e.attr("data-tinv-wl-productvariation",0),e.length&&e.attr("data-tinv-wl-list")){var s=JSON.parse(e.attr("data-tinv-wl-list")),l=!1,o="1"==window.tinvwl_add_to_wishlist.simple_flow;for(var a in s)s[a].hasOwnProperty("in")&&Array.isArray(s[a].in)&&-1<(s[a].in||[]).indexOf(0)&&(l=!0);e.toggleClass("tinvwl-product-in-list",l).toggleClass("tinvwl-product-make-remove",l&&o).attr("data-tinv-wl-action",l&&o?"remove":"addto")}
    • This reply was modified 3 months, 3 weeks ago by dowista.
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.