From 27c71fae8c74c6a4281eccaa480630ac9287bdee Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 31 Oct 2024 14:50:50 +0100 Subject: [PATCH] wip --- functions/product.php | 6 +++--- functions/tools.php | 34 +++++++++++++++++----------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/functions/product.php b/functions/product.php index d5f30cb0..c06093ec 100644 --- a/functions/product.php +++ b/functions/product.php @@ -263,10 +263,10 @@ function doliaddtocart($product, $mstock, $quantity, $price, $timestart = null, $oldquantity = $quantity; $quantity = $mstock['m2']; } - $thirdparty = callDoliApi("GET", "/thirdparties/".doliconnector($current_user, 'fk_soc'), null, dolidelay('thirdparty')); + $thirdparty = doliConnect('thirdparty', $current_user, false); if ( empty($orderid) ) { $rdr = [ - 'socid' => doliconnector($current_user, 'fk_soc'), + 'socid' => $thirdparty->id, 'date' => time(), 'demand_reason_id' => 1, 'cond_reglement_id' => $thirdparty->cond_reglement_id, @@ -489,7 +489,7 @@ function doliProductPrice($product, $quantity = null, $refresh = false, $nohtml global $current_user; $button = null; $price = array(); - $thirdparty = callDoliApi("GET", "/thirdparties/".doliconnector($current_user, 'fk_soc'), null, dolidelay('thirdparty')); + $thirdparty = doliConnect('thirdparty', $current_user, false); if (isset($thirdparty->tva_assuj) && empty($thirdparty->tva_assuj)) { if (isset($product->tva_tx)) $product->tva_tx = 0; } diff --git a/functions/tools.php b/functions/tools.php index 56173689..646994ec 100644 --- a/functions/tools.php +++ b/functions/tools.php @@ -1766,7 +1766,8 @@ function doliline($object, $refresh = false, $refreshstock = false, $wishlist = global $current_user; $doliline = null; //$doliline .= var_dump($object); - if ( isset($object) && is_object($object) && isset($object->lines) && $object->lines != null && (doliconnector($current_user, 'fk_soc') == $object->socid) ) { + $thirdparty = doliConnect('thirdparty', $current_user, false, $refresh); + if ( isset($object) && is_object($object) && isset($object->lines) && $object->lines != null && ($thirdparty->id == $object->socid) ) { foreach ( $object->lines as $line ) { if ( $line->fk_product > 0 ) { if ($refresh || $refreshstock) $refreshstock = true; @@ -1914,24 +1915,23 @@ function doliShipmentMethods($id, $refresh = false) { function doliconnect_paymentmethods($object = null, $module = null, $url = null, $refresh = false, $array = array()) { global $current_user; -$request = "/doliconnector/".doliconnector($current_user, 'fk_soc')."/paymentmethods"; - -if ( !empty($module) && is_object($object) && isset($object->id) ) { -if ($module == 'orders') { $module2 = 'order'; } -elseif ($module == 'invoices') { $module2 = 'invoice'; } -elseif ($module == 'donations') { $module2 = 'donation'; } -else { $module2 = $module; } -$request .= "?type=".$module2."&rowid=".$object->id; -$currency=strtolower($object->multicurrency_code?$object->multicurrency_code:'eur'); -$stripeAmount=($object->multicurrency_total_ttc?$object->multicurrency_total_ttc:$object->total_ttc)*100; -} + $thirdparty = doliConnect('thirdparty', $current_user, false, $refresh); + $request = "/doliconnector/".$thirdparty->id."/paymentmethods"; + + if ( !empty($module) && is_object($object) && isset($object->id) ) { + if ($module == 'orders') { $module2 = 'order'; } + elseif ($module == 'invoices') { $module2 = 'invoice'; } + elseif ($module == 'donations') { $module2 = 'donation'; } + else { $module2 = $module; } + $request .= "?type=".$module2."&rowid=".$object->id; + $currency=strtolower($object->multicurrency_code?$object->multicurrency_code:'eur'); + $stripeAmount=($object->multicurrency_total_ttc?$object->multicurrency_total_ttc:$object->total_ttc)*100; + } -$listpaymentmethods = callDoliApi("GET", $request, null, dolidelay('paymentmethods', $refresh)); -//print var_dump($listpaymentmethods); -$thirdparty = callDoliApi("GET", "/thirdparties/".doliconnector($current_user, 'fk_soc'), null, dolidelay('thirdparty', $refresh)); -//print $thirdparty; + $listpaymentmethods = callDoliApi("GET", $request, null, dolidelay('paymentmethods', $refresh)); + //print var_dump($listpaymentmethods); -$paymentmethods = ''; + $paymentmethods = ''; if ( isset($listpaymentmethods->stripe) ) { $paymentmethods .= '';