Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WORLD_BUISINESS : Atleast one item data is required #39

Open
visualight opened this issue Jul 5, 2024 · 0 comments
Open

WORLD_BUISINESS : Atleast one item data is required #39

visualight opened this issue Jul 5, 2024 · 0 comments

Comments

@visualight
Copy link

I don't understand what's missing for an international delivery. The API returns: "Atleast one item data is required" and refuses to create the label.

Here's my code :

$delivery_costs = $transporter->delivery_costs;

                    switch ($carrierData['weight']) {
                        case 2000:
                            $delivery_price = 'cost_1';
                            break;
                        default:
                            $delivery_price = 'cost_2';
                            break;
                    }

                    if (is_numeric($delivery_costs[$carrierData['country']][$delivery_price])) {
                        $temp_price = (float)$delivery_costs[$carrierData['country']][$delivery_price];

                        if ($temp_price >= 0.00 && $temp_price <= 999.99) {
                            $formatted_price = number_format($temp_price, 2);
                        } else {
                            // La valeur est en dehors des limites autorisées
                            $formatted_price = "0.00";
                        }
                    } else {
                        // La valeur n'est pas numérique
                        $formatted_price = "0.00";
                    }

                    $customsInfo = new Box\CustomsInfo\CustomsInfo();
                    $customsInfo->setParcelValue($carrierData['total']); // INT
                    $customsInfo->setCurrency(Bpost\Order\Box\CustomsInfo\CustomsInfo::CUSTOM_INFO_CURRENCY_EUR);
                    $customsInfo->setAmtPostagePaidByAddresse($formatted_price); //FLOAT : String
                    $customsInfo->setContentDescription('FASHION');
                    $customsInfo->setShipmentType(Bpost\Order\Box\CustomsInfo\CustomsInfo::CUSTOM_INFO_SHIPMENT_TYPE_GOODS);
                    $customsInfo->setParcelReturnInstructions(Bpost\Order\Box\CustomsInfo\CustomsInfo::CUSTOM_INFO_PARCEL_RETURN_INSTRUCTION_RTS);
                    $customsInfo->setPrivateAddress(true);

                    $international = new Box\International();
                    $international->setProduct(Bpost\ProductConfiguration\Product::PRODUCT_NAME_BPACK_WORLD_BUSINESS);
                    $international->setReceiver($receiver);
                    $international->setParcelWeight($carrierData['weight']);
                    $international->setCustomsInfo($customsInfo);

                    $box->setInternationalBox($international);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant