diff --git a/functions/data-request.php b/functions/data-request.php
index d36817d8..6dd24e1e 100644
--- a/functions/data-request.php
+++ b/functions/data-request.php
@@ -811,9 +811,9 @@ function dolicart_request() {
'lines' => $result['lines'],
'total' => $result['total']
];
- $response['modal'] = doliModalTemplate('CartInfos', __( 'Related products', 'doliconnect'), 'Message to do', '');
- 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');
+ 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'), 'to do', '', '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 87a4896f..16d661c5 100644
--- a/functions/product.php
+++ b/functions/product.php
@@ -9,6 +9,16 @@ function doliproduct($object, $value) {
}
}
+function doliCheckRelatedProducts($id) {
+ $request = "/relatedproducts/".$id;
+ $relatedproducts = callDoliApi("GET", $request, null, dolidelay('product', esc_attr(isset($_GET["refresh"]) ? $_GET["refresh"] : null)));
+ if ( !isset( $relatedproducts->error ) && $relatedproducts != null ) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
function doliprice($object = null, $mode = "ttc", $currency = null) {
global $current_user;
if ( is_object($object) ) {