Skip to content

Commit

Permalink
Update data-request.php
Browse files Browse the repository at this point in the history
  • Loading branch information
ptibogxiv committed Oct 1, 2023
1 parent 7451d47 commit 35438e1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions functions/data-request.php
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,9 @@ function dolicart_request() {
if (isset($_POST['modify']) && $_POST['modify'] == "delete") {
$price = doliProductPrice($product, 0, false, true);
$result = doliaddtocart($product, $mstock, 0, $price, null, null);
if (!empty(doliRequiredRelatedProducts($product->id, null, false))) {
$result = doliRequiredRelatedProducts($product->id, $qty, true);
}
$response = [
'message' => dolialert('success', $result['message']),
'newqty' => $result['newqty'],
Expand All @@ -805,7 +808,7 @@ function dolicart_request() {
$price = doliProductPrice($product, $qty, false, true);
$result = doliaddtocart($product, $mstock, $qty, $price, isset($_POST['product-add-timestamp_start'])?trim($_POST['product-add-timestamp_start']):null, isset($_POST['product-add-timestamp_end'])?trim($_POST['product-add-timestamp_end']):null);
if (!empty(doliRequiredRelatedProducts($product->id, null, false))) {
$result2 = doliRequiredRelatedProducts($product->id, $qty, true);
$result = doliRequiredRelatedProducts($product->id, $qty, true);
}
$response = [
'message' => dolialert('success', $result['message']),
Expand All @@ -815,8 +818,8 @@ function dolicart_request() {
'total' => $result['total']
];

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 (doliCheckModules('relatedproducts') && doliCheckRelatedProducts($product->id)) { $response['modal'] = doliModalTemplate('CartInfos', __( 'Related products', 'doliconnect'), doliRelatedProducts($product->id), '<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">'.__( "Close", "doliconnect").'</button>', 'modal-lg', null, 'p-0'); }
//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 (doliCheckModules('relatedproducts') && doliCheckRelatedProducts($product->id)) { $response['modal'] = doliModalTemplate('CartInfos', __( 'Related products', 'doliconnect'), doliRelatedProducts($product->id), '<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">'.__( "Close", "doliconnect").'</button>', 'modal-lg', null, 'p-0'); }
wp_send_json_success($response);
die();
} elseif (isset($_POST['modify']) && ($_POST['modify'] == "wish" || $_POST['modify'] == "unwish")) {
Expand Down

0 comments on commit 35438e1

Please sign in to comment.