-
Notifications
You must be signed in to change notification settings - Fork 40
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
feat(lune-integration): Add Lune integration custom shipping code and… #20
base: main
Are you sure you want to change the base?
Conversation
… transaction weebhook for CO2 shipping rate estimates and creating CO2 offset orders in Lune
|
8. In the Value field, enter your Lune API key | ||
9. Deploy the site | ||
|
||
### Create a new Foxy Weebhok |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a little change "Weebhok -> Webhook"
zoom=applied_taxes,billing_addresses,custom_fields,customer,discounts,items,items:item_category,items:item_options,payments,shipments,attributes | ||
``` | ||
|
||
Then click on `Update Weebhooks Next` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weebhooks -> Webhooks
const originAddress = "address goes here, city goes here"; | ||
|
||
// How to add the offset amount to the rates? | ||
// If set to false: Add rates with the CO2 offset estimate ammount included |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ammount->amount
|
||
// How to add the offset amount to the rates? | ||
// If set to false: Add rates with the CO2 offset estimate ammount included | ||
// If set to true: Keep regular rates, and duplicate them to add them with the CO2 offset estimate ammount included |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ammount->amount
// How to add the offset amount to the rates? | ||
// If set to false: Add rates with the CO2 offset estimate ammount included | ||
// If set to true: Keep regular rates, and duplicate them to add them with the CO2 offset estimate ammount included | ||
const addOffsetRatesSeparetly = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addOffsetRatesSeparetly->addOffsetRatesSeparately
shippingResultsEmissions.push(shippingEmissions); | ||
} | ||
|
||
// Add rates Separetly or Update rates with CO2 Offset amount |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Separetly->Separately
Number(price) + Number(quote.estimated_total_cost) | ||
).toFixed(2); | ||
|
||
if (addOffsetRatesSeparetly) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addOffsetRatesSeparetly->addOffsetRatesSeparately
(attr) => attr.name === `${ratePrefix}${selectedShippingRateID}` | ||
).value; | ||
|
||
const LUNE_API_KEY = config.lune.accessKey; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
config.lune.accessKey->config.lune.apiKey
const orderByEstimateIdUrl = "https://api.lune.co/v1/orders/by-estimate"; | ||
const response = await fetch(orderByEstimateIdUrl, { | ||
body: JSON.stringify({ | ||
estimate_id: "luneEstimateID", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
estimate_id: "luneEstimateID", -> estimate_id: luneEstimateID,
estimate_id: "luneEstimateID", | ||
metadata: { | ||
customer_email: cartDetails.customer_email, | ||
transaction_id: cartDetails.id, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
transaction_id: cartDetails.id, -> transaction_id: String(cartDetails.id),
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for all the individual comments.I tried to submit a branch to your own repo, but that didn't work.
And I guess you'll want to change the file name to |
const cartDetails = JSON.parse(requestEvent.body); | ||
const ratePrefix = "rate_id_"; | ||
const selectedShippingRateID = | ||
cartDetails["_embeded"]["fx:shipment"].shipping_service_id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cartDetails["_embeded"]["fx:shipment"].shipping_service_id; -> cartDetails["_embedded"]["fx:shipments"][0].shipping_service_id;
There can be multiple shipments for an order, so here I'm just getting the first one. not sure if we want to update the readme to note this limitation in the example
…ate README, and update shipment service ID varible
… transaction webhook for CO2 shipping rate estimates and creating CO2 offset orders in Lune