Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ptibogxiv committed Oct 1, 2023
1 parent 02d6d25 commit 613db55
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions functions/data-request.php
Original file line number Diff line number Diff line change
Expand Up @@ -804,8 +804,8 @@ 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, false))) {
$result2 = doliRequiredRelatedProducts($product->id, true);
if (!empty(doliRequiredRelatedProducts($product->id, null, false))) {
$result2 = doliRequiredRelatedProducts($product->id, $qty, true);
}
$response = [
'message' => dolialert('success', $result['message']),
Expand Down
4 changes: 2 additions & 2 deletions functions/product.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ function doliproduct($object, $value) {
}
}

function doliRequiredRelatedProducts($id, $valid = false) {
function doliRequiredRelatedProducts($id, $qty = null, $valid = false) {
$request = "/relatedproducts/".$id."?required=true";
$relatedproducts = callDoliApi("GET", $request, null, dolidelay('product', esc_attr(isset($_GET["refresh"]) ? $_GET["refresh"] : null)));
if ( !isset( $relatedproducts->error ) && $relatedproducts != null ) {
if (empty($valid)) {
return true;
} else {
foreach ( $relatedproducts as $product ) {
$qty = $product->qty;
$qty2 = $qty*$product->qty;
$product = callDoliApi("GET", "/products/".$product->id."?includestockdata=1&includesubproducts=true&includetrans=true", null, dolidelay('product', true));
$mstock = doliProductStock($product, false, true);
$price = doliProductPrice($product, $qty, false, true);
Expand Down

0 comments on commit 613db55

Please sign in to comment.