Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ptibogxiv committed Sep 27, 2023
1 parent 7dd5c44 commit 1f5c6fc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions functions/data-request.php
Original file line number Diff line number Diff line change
Expand Up @@ -811,9 +811,9 @@ function dolicart_request() {
'lines' => $result['lines'],
'total' => $result['total']
];
$response['modal'] = doliModalTemplate('CartInfos', __( 'Related products', 'doliconnect'), 'Message to do', '<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">'.__( "Close", "doliconnect").'</button>');

if ($qty != $result['newqty']) $response['modal'] = doliModalTemplate('CartInfos', __( 'Cart', 'doliconnect'), __( 'This item is not available in this quantity!', 'doliconnect'), '<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">'.__( "Continue shopping", "doliconnect").'</button> <a class="btn btn-primary" role="button" href="'.esc_url(doliconnecturl('dolicart')).'" >'.__( 'Finalize the order', 'doliconnect').'</a>', 'modal-lg');
if ($qty != $result['newqty']) { $response['modal'] = doliModalTemplate('CartInfos', __( 'Cart', 'doliconnect'), __( 'This item is not available in this quantity!', 'doliconnect'), '<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">'.__( "Continue shopping", "doliconnect").'</button> <a class="btn btn-primary" role="button" href="'.esc_url(doliconnecturl('dolicart')).'" >'.__( 'Finalize the order', 'doliconnect').'</a>', 'modal-lg'); }
elseif (doliCheckRelatedProducts($product->id)) { $response['modal'] = doliModalTemplate('CartInfos', __( 'Related products', 'doliconnect'), 'to do', '<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">'.__( "Close", "doliconnect").'</button>', 'modal-lg'); }
wp_send_json_success($response);
die();
} elseif (isset($_POST['modify']) && ($_POST['modify'] == "wish" || $_POST['modify'] == "unwish")) {
Expand Down
10 changes: 10 additions & 0 deletions functions/product.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) ) {
Expand Down

0 comments on commit 1f5c6fc

Please sign in to comment.