/
NUTRINTG Shopify reorder - rejected

NUTRINTG Shopify reorder - rejected

Questions to answer:

  1. What is the maximum line item number (this will be important to the SFMC team) Answer: 15 items

  2. Do we need individual_Id (from Epsilon)? Answer: Yes, we send it as a Key to SFMC

Short description:

  1. Customer may use reorder functionality and customize the frequency

  2. Re-order works in the following way:

    1. Customer can select reorder option for a particular order and include frequency for reorder

    2. SFMC send a specially prepared link, which opens the cart with all the product

    3. SFMC send above e-mail with the frequency provided by the customer

    4. So that the customer's only duty is to finalize the order

Flow:

#

step

description

#

step

description

1

User checks whether wants reorder

  • There are two additional fields in the check-out view in Shopify

    • check-box: "true" (string) if the customer wants to reorder

    • Frequency: predefined terms of possible reorder (example: 5, 10, 15, 30, 45, 60 days)

2.

Shopify back-end save the custom value

  • "note_attributes": [ {"reorder":
    {
    "reorder_check": "true"/"false", "frequency": "45"
    } } ]

    Note_attributes are extra information that is added to the order. Appears in the Additional details section of an order details page. Each array entry must contain a hash with name and value keys.

  • This is no longer valid, reoder service will determine if requets are applicable based on shopify domain. Whole domains will be enrolled for the roerder functionality. 

  • Frequency will be stored together with shopify domain.

3.

Middleware order service

4.

Anypoint Exchange

  • Duplicate message and send to the Clients' (Reorder service, Order Adapter) queues

  • Clients: 

    • Order Adapter

    • Reorder service

5.

Order Adapter flow

  • Take requests from the queue and proceed to create csv files

6.

MW Re-Order service

  • Take requests from the queue

  • Order service checks for "reorder_check" value (true/false)

  • In case:

    • "reorder" : "false".   Shopify domain is not enrolled for reorder

      • drop

    • "reorder" : "true"    Shopify domain is enrolled for reorder

      • proceed

  • Shopify domains and their frequencies are stored in mongo collection cdpReorderService_shopifyDomains: example document look like this:

7. 

Call GetIndividualId service

  • New service should be created for getting individual of the customer

  • REST

  • Endpoint:

  • Authorization:

  • IndividualId value is retrieved from CDP by "Get Profiles (Search)" CDP API method

  • In case no account is found, the data has to be sent to Salesforce with other event ID and with email as ContactKey.

8.

Extracting relevant fields and values

  • Extract:

    • email

    • order_id

    • created_at

    • shipping_address

      • address1

      • address2

      • phone

      • city

      • zip

    • first_name

    • last_name

    • Accepts marketing from customer object ("customer": { "id": 115310627314723954, "email": "john@test.com", "accepts_marketing": false)

    • For each line_item:

      • variant_id

      • quantity

      • price

  • Example order webhook JSON:



Example order webhook JSON
{ "id": 820982911946154508, "email": "jon@doe.ca", "closed_at": null, "created_at": "2019-12-18T12:06:00-05:00", "updated_at": "2019-12-18T12:06:00-05:00", "number": 234, "note": null, "token": "123456abcd", "gateway": null, "test": true, "total_price": "403.00", "subtotal_price": "393.00", "total_weight": 0, "total_tax": "0.00", "taxes_included": false, "currency": "USD", "financial_status": "voided", "confirmed": false, "total_discounts": "5.00", "total_line_items_price": "398.00", "cart_token": null, "buyer_accepts_marketing": true, "name": "#9999", "referring_site": null, "landing_site": null, "cancelled_at": "2019-12-18T12:06:00-05:00", "cancel_reason": "customer", "total_price_usd": null, "checkout_token": null, "reference": null, "user_id": null, "location_id": null, "source_identifier": null, "source_url": null, "processed_at": null, "device_id": null, "phone": null, "customer_locale": "en", "app_id": null, "browser_ip": null, "landing_site_ref": null, "order_number": 1234, "discount_applications": [ { "type": "manual", "value": "5.0", "value_type": "fixed_amount", "allocation_method": "one", "target_selection": "explicit", "target_type": "line_item", "description": "Discount", "title": "Discount" } ], "discount_codes": [ ], "note_attributes": [ ], "payment_gateway_names": [ "visa", "bogus" ], "processing_method": "", "checkout_id": null, "source_name": "web", "fulfillment_status": "pending", "tax_lines": [ ], "tags": "", "contact_email": "jon@doe.ca", "order_status_url": "https:\/\/apple.myshopify.com\/690933842\/orders\/123456abcd\/authenticate?key=abcdefg", "presentment_currency": "USD", "total_line_items_price_set": { "shop_money": { "amount": "398.00", "currency_code": "USD" }, "presentment_money": { "amount": "398.00", "currency_code": "USD" } }, "total_discounts_set": { "shop_money": { "amount": "5.00", "currency_code": "USD" }, "presentment_money": { "amount": "5.00", "currency_code": "USD" } }, "total_shipping_price_set": { "shop_money": { "amount": "10.00", "currency_code": "USD" }, "presentment_money": { "amount": "10.00", "currency_code": "USD" } }, "subtotal_price_set": { "shop_money": { "amount": "393.00", "currency_code": "USD" }, "presentment_money": { "amount": "393.00", "currency_code": "USD" } }, "total_price_set": { "shop_money": { "amount": "403.00", "currency_code": "USD" }, "presentment_money": { "amount": "403.00", "currency_code": "USD" } }, "total_tax_set": { "shop_money": { "amount": "0.00", "currency_code": "USD" }, "presentment_money": { "amount": "0.00", "currency_code": "USD" } }, "shipping_lines": [ { "id": 271878346596884015, "title": "Generic Shipping", "price": "10.00", "code": null, "source": "shopify", "phone": null, "requested_fulfillment_service_id": null, "delivery_category": null, "carrier_identifier": null, "discounted_price": "10.00", "price_set": { "shop_money": { "amount": "10.00", "currency_code": "USD" }, "presentment_money": { "amount": "10.00", "currency_code": "USD" } }, "discounted_price_set": { "shop_money": { "amount": "10.00", "currency_code": "USD" }, "presentment_money": { "amount": "10.00", "currency_code": "USD" } }, "discount_allocations": [ ], "tax_lines": [ ] } ], "billing_address": { "first_name": "Bob", "address1": "123 Billing Street", "phone": "555-555-BILL", "city": "Billtown", "zip": "K2P0B0", "province": "Kentucky", "country": "United States", "last_name": "Biller", "address2": null, "company": "My Company", "latitude": null, "longitude": null, "name": "Bob Biller", "country_code": "US", "province_code": "KY" }, "shipping_address": { "first_name": "Steve", "address1": "123 Shipping Street", "phone": "555-555-SHIP", "city": "Shippington", "zip": "40003", "province": "Kentucky", "country": "United States", "last_name": "Shipper", "address2": null, "company": "Shipping Company", "latitude": null, "longitude": null, "name": "Steve Shipper", "country_code": "US", "province_code": "KY" }, "customer": { "id": 115310627314723954, "email": "john@test.com", "accepts_marketing": false, "created_at": null, "updated_at": null, "first_name": "John", "last_name": "Smith", "orders_count": 0, "state": "disabled", "total_spent": "0.00", "last_order_id": null, "note": null, "verified_email": true, "multipass_identifier": null, "tax_exempt": false, "phone": null, "tags": "", "last_order_name": null, "currency": "USD", "accepts_marketing_updated_at": null, "marketing_opt_in_level": null, "default_address": { "id": 715243470612851245, "customer_id": 115310627314723954, "first_name": null, "last_name": null, "company": null, "address1": "123 Elm St.", "address2": null, "city": "Ottawa", "province": "Ontario", "country": "Canada", "zip": "K2H7A8", "phone": "123-123-1234", "name": "", "province_code": "ON", "country_code": "CA", "country_name": "Canada", "default": true } }, "line_items": [ { "id": 866550311766439020, "variant_id": 808950810, "title": "IPod Nano - 8GB", "quantity": 1, "sku": "IPOD2008PINK", "variant_title": null, "vendor": null, "fulfillment_service": "manual", "product_id": 632910392, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "IPod Nano - 8GB", "variant_inventory_management": "shopify", "properties": [ ], "product_exists": true, "fulfillable_quantity": 1, "grams": 567, "price": "199.00", "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "199.00", "currency_code": "USD" }, "presentment_money": { "amount": "199.00", "currency_code": "USD" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "USD" }, "presentment_money": { "amount": "0.00", "currency_code": "USD" } }, "discount_allocations": [ ], "tax_lines": [ ] }, { "id": 141249953214522974, "variant_id": 808950810, "title": "IPod Nano - 8GB", "quantity": 1, "sku": "IPOD2008PINK", "variant_title": null, "vendor": null, "fulfillment_service": "manual", "product_id": 632910392, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "IPod Nano - 8GB", "variant_inventory_management": "shopify", "properties": [ ], "product_exists": true, "fulfillable_quantity": 1, "grams": 567, "price": "199.00", "total_discount": "5.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "199.00", "currency_code": "USD" }, "presentment_money": { "amount": "199.00", "currency_code": "USD" } }, "total_discount_set": { "shop_money": { "amount": "5.00", "currency_code": "USD" }, "presentment_money": { "amount": "5.00", "currency_code": "USD" } }, "discount_allocations": [ { "amount": "5.00", "discount_application_index": 0, "amount_set": { "shop_money": { "amount": "5.00", "currency_code": "USD" }, "presentment_money": { "amount": "5.00", "currency_code": "USD" } } } ], "tax_lines": [ ] } ], "fulfillments": [ ], "refunds": [ ] }



9.

Create a reorder cart URL

  • The link should be created according to the below specification:

    •  

      • The Shopify domain | example: http://your-store.myshopify.com

      • /cart/

      • variantID:quantity (first product) | example: 70881412:1

      • variantID:quantity (second product) | example: 70881382:1



    • other prefilled values:

      • checkout[email]

      • checkout[shipping_address][first_name]

      • checkout[shipping_address][last_name]

      • checkout[shipping_address][address1]

      • checkout[shipping_address][address2]

      • checkout[shipping_address][city]

      • checkout[shipping_address][zip]



  • Example URL for a link with prefilled email and city parameters:

http://your-store.myshopify.com/cart/70881412:1,70881382:1?checkout[email]=somebody@store.com&checkout[shipping_address][city]=thisismyhometown

  • Log: order_id, timestamp, reorder_URL

More info: https://help.shopify.com/en/themes/customization/cart/use-permalinks-to-preload-cart

10.

Check for relevant Event Definition Key

  • In MongoDB there is a mapping: domain : Event Definition Key (to be confirmed with SF team)

  • Relevant Event Definition Key is extracted

11.

Consolidate the body of the request sent to SFMC

The body request includes:

example request
Body: "ContactKey": flowVars.message.individualId, "EventDefinitionKey": flowVars.sfEventId.eventId, "Data": { "Individual_ID": flowVars.message.individualId, "order_id": flowVars.message.order_id, "created_at": flowVars.message.created_at, "firstName": flowVars.message.firstName, -- (from CUSTOMER OBJECT IN ORDER PAYLOAD) "lastName": flowVars.message.lastName, -- (from CUSTOMER OBJECT IN ORDER PAYLOAD) "email": flowVars.message.email, "accept_marketing": flowVars.message.accept_marketing, "reorder_frequency": flowVars.message.frequency "reorder_URL": flowVars.message.reorder_URL, "variant_id_1": flowVars.message.variant_1, "quantity_1": flowVars.message.quantity_1, "price_1": flowVars.message.price_1, "variant_id_2": flowVars.message.variant_2, "quantity_2": flowVars.message.quantity_2, "price_2": flowVars.message.price_2 }
  • Event Definition Key for test purposes: APIEvent-4b6fd87d-cef9-4e0d-f802-cadff42bb637

12.

Pass prepared body request to the "send to SFMC service"



13.

Send to SFMC service

  • Service should be REST

  • Endpoint:

  • Authorization:

  • New service should be created

  • Service authorize itself in the SFMC

  • Service sends the request to the SFMC



    example request

    Host: https://mc1plnsfxggrfg-l69pj913rd1x4.rest.marketingcloudapis.com/interaction/v1/events Headers: Authorization: Bearer #[flowVars.accessToken] Body: {}