Hello everyone,
I am facing an “issue” trying to add an order via API of cs-cart. Let me explain:
I have a product that has min_qty = 8
I have an external web app that sends to cs-cart admin panel orders via API. Clients are buying the above product but has amount equals to 1. I can not change this web app to have min qty… Now, if I send the order to cs-cart via API I have this product, but with the min_qty = 8. Is there a work arround to pass the real quantity that client choose? if it’s qty = 2, I want to see 2 and so on…
Please, let me know if you need furhter information in order to explain it better!
thanks in advance
I can assume that some code modification will be required to bypass this limitation
You can try this modification via the My Changes add-on (not tested):
app/add-ons/my_changes/func.php:
<?php
defined('BOOTSTRAP') or die('Access denied');
function fn_my_changes_check_amount_in_stock_before_check(
$product_id,
$amount,
$product_options,
$cart_id,
$is_edp,
$original_amount,
$cart,
$update_id,
&$product,
$current_amount,
$skip_error_notification
) {
if (defined('API')) {
$min_qty = 1;
$product['qty_step'] = floor((float) $product['qty_step']);
if (!empty($product['min_qty']) && $product['min_qty'] > $min_qty) {
$min_qty = fn_ceil_to_step($product['min_qty'], $product['qty_step']);
}
if (!empty($product['qty_step']) && $product['qty_step'] > $min_qty) {
$min_qty = $product['qty_step'];
}
if ($product['amount'] > 0 && $product['amount'] < $min_qty)
{
$product['min_qty'] = $product['qty_step'] = 1;
}
}
}
app/add-ons/my_changes/init.php:
<?php
defined('BOOTSTRAP') or die('Access denied');
fn_register_hooks('check_amount_in_stock_before_check');