checkoutshipping model (front) - shipping params

01.12.2021 09:49
#1
sergeytolkachyov
User sergeytolkachyov
Name: Sergey
11.10.2019
Posts: 110
Quote
checkoutshipping model (front) - shipping params

Hello. Function showForm ($shipping_id, $shippinginfo, $params) for shipping form gets a third argument $param. This argument loads in checkoutshipping model (components/com_jshopping/models/checkoutshipping.php), method getCheckoutListShippings.
But it loads only for active shipping method

if ($value->sh_pr_method_id==$active_shipping){
$params = $cart->getShippingParams();
}else{
$params = array();
}

This $param we can set via $cart->setShippingParams($val), that stores data in the session.
It would be comfortable to have an ability to get params from each shipping method to their shipping form by this way. But now I can get it only for active shipping method.

This situation form JoomShopping 4.18.7, but I think in JoomShopping 5 used the same way.


Joomla developer. https://web-tolk.ru JoomShopping Bitrix24 integration, custom developing.
 
01.12.2021 10:04
#2
admin
(Support Team)
User admin
Name: Admin
05.08.2010
Posts: 25922
Quote
Aw: checkoutshipping model (front) - shipping params

Why do you need parameters from inactive delivery?

 
02.12.2021 08:50
#3
sergeytolkachyov
User sergeytolkachyov
Name: Sergey
11.10.2019
Posts: 110
Quote
Aw: checkoutshipping model (front) - shipping params

Example: i made an extension for price calculation for shipping. I get a pick-up points addresses, shipping cost and other information from API of delivery company. In shippingextRoot -> myClass -> getPrice I got this info, but I must show for user this info - not only the price (wich returns in getPrice), but also the address of the pick-up point, its working hours, a widget with a map - all of this I must show via ShippingFormRoot -> myClassForm. And then set the shipping form param to display its in order.

In forntend: we have <div class="shipping_form_active">. This css-class assignes to selected shipping method by js when we clicks on methods. In this <div> I can show additional info about shipping. But now there is only one shipping method has this additional info, because in php only active shipping can get it. All others got an empty array. Of course I can set this info in session (like native model do), but I think native way will be better.


Joomla developer. https://web-tolk.ru JoomShopping Bitrix24 integration, custom developing.
 
02.12.2021 09:12
#4
admin
(Support Team)
User admin
Name: Admin
05.08.2010
Posts: 25922
Quote
Aw: checkoutshipping model (front) - shipping params

I didn't fully understand your idea.
array params - needed to save information in the order (active shipping data)

 
02.12.2021 09:59
#5
sergeytolkachyov
User sergeytolkachyov
Name: Sergey
11.10.2019
Posts: 110
Quote
Aw: checkoutshipping model (front) - shipping params

Yes, that's right. But in order to save the delivery information in the order, you need to get it at the stage of choosing the delivery method. And at the moment in shippingform there is an opportunity to receive data of only one - active - delivery method. If there are several delivery methods, only the active one receives additional information. the rest do not receive

In practice, the store can have up to 10+ shipping methods and 5+ extensions for calculating the cost of delivery. For each of the methods, you need to transfer your data from the extensions for calculate shipping price to shippingform.

If you transfer data from shippingextform to all shippingforms. by separating them by id, it would be convenient. And for the further steps of the order, leave only the necessary data - leave everything as it is. We are talking only about the step of choosing the delivery method.


Last change: 02.12.2021 10:18

Joomla developer. https://web-tolk.ru JoomShopping Bitrix24 integration, custom developing.
 
02.12.2021 10:30
#6
admin
(Support Team)
User admin
Name: Admin
05.08.2010
Posts: 25922
Quote
Aw: checkoutshipping model (front) - shipping params

I think you are using params incorrectly in your addon.
params - saved only after select shipping.

-----------------------------------------------------------------------------
$allparams = $this->input->getVar('params');
$params = $allparams[$sh_method->shipping_id];

if (isset($params)){
$cart->setShippingParams($params);
}else{
$cart->setShippingParams('');
}
for order need only active shipping

-------------------------------------------------------------------------------

Use trigger
onBeforeSaveCheckoutStep4save
for save all params data


Last change: 02.12.2021 10:40
 
06.12.2021 09:16
#7
sergeytolkachyov
User sergeytolkachyov
Name: Sergey
11.10.2019
Posts: 110
Quote
Aw: checkoutshipping model (front) - shipping params

My question is about how to transfer additional shipping data from shipping extension to shipping form. Now I'm not using the $params in shippingforn because it's impossible. But we need in active shipping only after saving checked shipping method in checkout.
Aw: checkoutshipping model (front) - shipping params


Last change: 06.12.2021 10:57

Joomla developer. https://web-tolk.ru JoomShopping Bitrix24 integration, custom developing.
 
06.12.2021 11:35
#8
admin
(Support Team)
User admin
Name: Admin
05.08.2010
Posts: 25922
Quote
Aw: checkoutshipping model (front) - shipping params

Your need params from getPrices
function getPrices($cart, $params, $prices, &$shipping_ext_row, &$shipping_method_price)

see
table/shippingmethodprice.php
getParams()

 
06.12.2021 12:00
#9
sergeytolkachyov
User sergeytolkachyov
Name: Sergey
11.10.2019
Posts: 110
Quote
Aw: checkoutshipping model (front) - shipping params

No, I need in additional data, wich I got in getPrices from external API, in shippingform ))
So, in getPrices I got from external API a list of pick-up points, its addresses etc end then transfer this info to shippingform for frontend. Now I do this via session, but I saw a $params as argument and try to understand it.


Joomla developer. https://web-tolk.ru JoomShopping Bitrix24 integration, custom developing.
 


Copyrights MAXXmarketing GmbH. Alle Rechte vorbehalten
Durch die Nutzung dieser Website stimme ich zu, dass Cookies zur optimalen Gestaltung der Website sowie zur Analyse der Nutzung der Website verwendet werden. Weiterführende Informationen finden Sie hier. OK, einverstanden.