WPIntell

Source evidence

Error with simple products

Variation Auto Expire For WooCommerce · support · 2023-04-28T18:43:00+00:00

mixedsentiment
highseverity
0.82relevance
2replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

10 / 67 rows with source links

14.9% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

57 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
Letícia Moreira resolved
Hello, First of all, nice work with the plugin! I was facing a problem where simple products where being affected by plugin’s logic even though it should not consider simple products. Not sure if the situation happened just to me, but for precaution I thought it would be better to inform you. Currently using WordPress 6.2 and WooCommerce 7.3. I fixed it by modifying the Ycve_Public class, line 149, where it makes the validation. Thanks for your input, it was very useful. I’ve contained a slightly wider block of code within the new condition… /** * Check at checkout if any * * @access public * @since 1.0.0 * @param Array $fields * @param Object $errors */ public function ycve_variation_validate_dt( $fields, $errors ){ foreach ( WC()->cart->cart_contents as $key => $item ) { $product_id = $item['product_id']; $product = wc_get_product( $product_id ); // Check if the product is a variable product if ( $product->is_type( 'variable' ) ) { $variations = $product->get_children(); if( ! empty( $variations ) ){ foreach( $variations as $variation ){ $this->ycve_check_exp_date_to( $variation ); } } $newProduct = wc_get_product( $product_id ); $newVariations = $newProduct->get_children(); if ( ! in_array( $item['variation_id'], $newVariations ) ) { $name = $item['data']->get_name(); $itemsCount = count( WC()->cart->get_cart() ); $cart_url = wc_get_cart_url(); $errorMsg = '<b>' . $name . '</b> it is really not available! already removed from cart!! <a href="' . $cart_url . '"><b>Check cart</b></a>'; if( $itemsCount > 1 ){ $errorMsg = 'Product: <b>' . $name . '</b> in your cart, it is really not available and already removed from cart!! <a href="' . $cart_url . '"><b>Check cart</b></a>'; } $errors->add( 'validation', $errorMsg ); } } }//cart end } Hello, thanks for the bug correction! I’ll correct this in next update.

Comments

2 shown
kwebdesign 2023-05-04T20:46:00+00:00

Thanks for your input, it was very useful. I’ve contained a slightly wider block of code within the new condition… /** * Check at checkout if any * * @access public * @since 1.0.0 * @param Array $fields * @param Object $errors */ public function ycve_variation_validate_dt( $fields, $errors ){ foreach ( WC()->cart->cart_contents as $key => $item ) { $product_id = $item['product_id']; $product = wc_get_product( $product_id ); // Check if the product is a variable product if ( $product->is_type( 'variable' ) ) { $variations = $product->get_children(); if( ! empty( $variations ) ){ foreach( $variations as $variation ){ $this->ycve_check_exp_date_to( $variation ); } } $newProduct = wc_get_product( $product_id ); $newVariations = $newProduct->get_children(); if ( ! in_array( $item['variation_id'], $newVariations ) ) { $name = $item['data']->get_name(); $itemsCount = count( WC()->cart->get_cart() ); $cart_url = wc_get_cart_url(); $errorMsg = '<b>' . $name . '</b> it is really not available! already removed from cart!! <a href="' . $cart_url . '"><b>Check cart</b></a>'; if( $itemsCount > 1 ){ $errorMsg = 'Product: <b>' . $name . '</b> in your cart, it is really not available and already removed from cart!! <a href="' . $cart_url . '"><b>Check cart</b></a>'; } $errors->add( 'validation', $errorMsg ); } } }//cart end }

yakacj 2023-05-17T17:17:00+00:00

Hello, thanks for the bug correction! I’ll correct this in next update.