MyParcel Checkout
Introduction
This is the MyParcel checkout module. It's used to show your customers the possible delivery and/or pickup options for their location, based on your settings. It barely has any css styling by itself so it should integrate with the design of your website easily.
Support
The checkout is written in Vue.js, it supports IE9 and up.
Example
An example of the checkout functionality can be found in our sandbox. Here you can try out every combination of settings and copy the code for your project.
Installation
- Clone the repository or download the latest package from releases.
- Run the following commands:
$ npm i
$ npm run build
- Include
dist/myparcel.js
in your project. - Place
<div id="myparcel-checkout"></div>
in your HTML. - The checkout will be rendered inside that element!
Usage
You have to provide a configuration file in the following format as window.MyParcelConfig
and initialize the checkout with an event.
Minimum required data
This is the minimum amount of data you need to provide for the checkout to work correctly as a SendMyParcel user.
window.MyParcelConfig = {
config: {
platform: 'belgie',
},
address: {
cc: 'BE',
city: 'Antwerpen',
postalCode: '1000',
}
};
document.dispatchEvent(new Event('myparcel_update_checkout'));
All options
window.MyParcelConfig = {
config: {
platform: 'belgie',
carriers: ['bpost', 'dpd'],
priceMorningDelivery: 7.95,
priceStandardDelivery: 5.85,
priceEveningDelivery: 6.25,
priceSignature: 0.35,
priceOnlyRecipient: 0.30,
pricePickup: 5.85,
allowSaturdayDelivery: true,
allowPickupPoints: true,
allowSignature: true,
dropOffDays: '1;2;3;4;5;6',
cutoffTime: '15:00',
deliveryDaysWindow: 4,
dropOffDelay: 1,
carrierSettings: {
bpost: {
deliveryDaysWindow: 7,
},
dpd: {},
},
},
strings: {
wrongPostalCodeCity: 'Zaterdaglevering',
saturdayDeliveryTitle: 'Combinatie postcode/plaats onbekend',
city: 'Plaats',
postcode: 'Postcode',
houseNumber: 'Huisnummer',
addressNotFound: 'Adresgegevens niet ingevuld',
deliveryEveningTitle: 'Avondlevering',
deliveryMorningTitle: 'Ochtendlevering',
deliveryStandardTitle: 'Standaardlevering',
deliveryTitle: 'Bezorgen op',
pickupTitle: 'Afhalen op locatie',
onlyRecipientTitle: 'Home address only',
signatureTitle: 'Handtekening',
pickUpFrom: 'Afhalen vanaf',
openingHours: 'Openingstijden',
closed: 'Gesloten',
discount: 'korting',
free: 'Gratis',
from: 'Vanaf',
loadMore: 'Laad meer',
retry: 'Opnieuw',
},
address: {
cc: 'BE',
city: 'Antwerpen',
postalCode: '1000',
}
};
When there is no title set for deliveryMorningTitle
, deliveryStandardTitle
or deliveryEveningTitle
, the delivery time will automatically be visible. For more in-depth explanation of each config item and string and an interactive demo please see our sandbox
To get the object with the selected options from the checkout do the following:
const data = document.querySelector('#mypa-input').value;
const obj = JSON.parse(data);
Contribute
- Clone this repository
- Run
npm install
- Make your changes conforming to the existing code style, we recommend enabling ESLint and using our configuration to make this easier.
- Test the new code using
npm run serve
- Create a pull request!
Support
If you're experiencing trouble with the implementation we're ready to help you out! Please reach out to us via support@sendmyparcel.be