I try to recieve additional data to my custom shipping method.
I get some info from checkout page and put it in my custom object quote.pickPoint
.
Then, I add it to shipping-save-processor:
payload = {
addressInformation: {
shipping_address: quote.shippingAddress(),
billing_address: quote.billingAddress(),
shipping_method_code: quote.shippingMethod().method_code,
shipping_carrier_code: quote.shippingMethod().carrier_code
},
pickPoint: quote.pickPoint()
};
In my custom shipping method I try to get additional info:
$rawReq = json_decode(file_get_contents('php://input'), true);
And then $rawReq
contains correct array with my data
Array
(
[addressInformation] => Array
(
[shipping_address] => Array
(
[countryId] => RU
[region] => Russian Federation
[street] => Array
(
)
[telephone] => +79161234567
[postcode] =>
[city] => Moscow
[firstname] => Pavel
[lastname] => Shi
)
[billing_address] => Array
(
[countryId] => RU
[region] => Russian Federation
[street] => Array
(
)
[telephone] => +79161234567
[postcode] =>
[city] => Moscow
[firstname] => Pavel
[lastname] => Shi
[saveInAddressBook] =>
)
[shipping_method_code] => svyaznoy
[shipping_carrier_code] => svyaznoy
)
[pickPoint] => Array
(
[city] => Москва
[region] => Москва г
[address] => 105120 Золоторожский Вал ул 42
[deliveryCost1] => 149
[deliveryCost2] => 158
[deliveryCost3] => 167
[deliveryCost4] => 176
[deliveryCost5] => 176
[deliveryCost6] => 176
[deliveryCost7] => 176
[deliveryCost8] => 176
[hash] => 691C7765E7B8EB872246B667E3617141
[hash8] => 12A8F948EFCEEE375836B37705674CC2
[hash16] => 1C307A3D17989B48487DF19563111DE1
[name] => Площадь Ильича
[returnCost1] => 238.4
[returnCost2] => 238.4
[returnCost3] => 238.4
[returnCost4] => 238.4
[returnCost5] => 238.4
[returnCost6] => 238.4
[returnCost7] => 238.4
[returnCost8] => 238.4
[shopId] => MD34
[deliveryOperatorId] => 1
[deliveryOperator] => Евросеть
)
)
BUT!
When I try to set price and cost, its not working.
This code working:
$amount = 0;
$amount = 1;
$method->setPrice($amount);
$method->setCost($amount);
But this code not working:
$amount = 0;
if (isset $rawReq['pickPoint']) {
$amount = 123;
}
$method->setPrice($amount);
$method->setCost($amount);
Shipping method always return 0 price.
Why?
Thanks beforehand!