diff --git a/functions/data-request.php b/functions/data-request.php index 3992164f..fcb3e0ea 100644 --- a/functions/data-request.php +++ b/functions/data-request.php @@ -813,7 +813,7 @@ function dolicart_request() { ]; if ($qty != $result['newqty']) { $response['modal'] = doliModalTemplate('CartInfos', __( 'Cart', 'doliconnect'), __( 'This item is not available in this quantity!', 'doliconnect'), ' '.__( 'Finalize the order', 'doliconnect').'', 'modal-lg'); } - elseif (doliCheckRelatedProducts($product->id)) { $response['modal'] = doliModalTemplate('CartInfos', __( 'Related products', 'doliconnect'), doliRelatedProducts($product->id), '', 'modal-lg'); } + elseif (doliCheckModules('relatedproducts') && doliCheckRelatedProducts($product->id)) { $response['modal'] = doliModalTemplate('CartInfos', __( 'Related products', 'doliconnect'), doliRelatedProducts($product->id), '', 'modal-lg'); } wp_send_json_success($response); die(); } elseif (isset($_POST['modify']) && ($_POST['modify'] == "wish" || $_POST['modify'] == "unwish")) { diff --git a/functions/product.php b/functions/product.php index 4bac9cfa..564ebe3f 100644 --- a/functions/product.php +++ b/functions/product.php @@ -25,7 +25,7 @@ function doliRelatedProducts($id) { if ( !isset( $relatedproducts->error ) && $relatedproducts != null ) { $related = null; foreach ( $relatedproducts as $product ) { - $related .= apply_filters( 'doliproductlist', $product->id); + $related .= apply_filters( 'doliproductlist', $product); } return $related; } else { @@ -659,7 +659,7 @@ function doliproductlist($product) { global $current_user; $wish = 0; -if (!empty($product->qty)) { +if (isset($product->fk_product) && !empty($product->qty)) { $wish = $product->qty; $product = callDoliApi("GET", "/products/".$product->fk_product."?includestockdata=1&includesubproducts=true&includetrans=true", null, dolidelay('product', esc_attr(isset($_GET["refresh"]) ? $_GET["refresh"] : null))); } else {