Code Monkey home page Code Monkey logo

sfcc_klaviyo's Introduction

Klaviyo Cartridge for B2C Commerce

This is the Salesforce Certified Commerce Cloud Cartridge to integrate Klaviyo.

Installation

Installation instructions can be found in the Klaviyo Help Center.

Contributing

We appreciate any and all contributions to this project! Before creating an issue or raising a PR, review our Contributing guide. This guide reviews issue creation, prerequisites for pull requests, and more.

sfcc_klaviyo's People

Contributors

aidrian-maze avatar aidrianoconnor avatar award28 avatar cykolln avatar dknight-mazegroup avatar emarty-maze avatar jordanallain avatar jordanleslie avatar lcalvy avatar mangoceylon2 avatar njparadis avatar remstone7 avatar ryankelly-klaviyo avatar smoucka avatar wbendris-klaviyo avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sfcc_klaviyo's Issues

phone number is not removed when service call fails due to bad phone number

Environment details

SiteGenesis or Storefront Reference Architecture: SFRA
Klaviyo Cartridge version: 24.1.0
Anything else that would help a developer reproduce the bug?

Steps to reproduce

Go through the checkout flow, inputting a phone number that does not start with +1.
Follow the code in the subscribeUser() function within utils.js and inspect the returned result on line 257.
Notice the text of the error message indicates a bad phone number, but the pointer field has a value of "/data".
Notice the code that is meant to remove a bad phone number from the data and resend the service call does not run, because the pointer doesn't have a value of "phone_number"

Expected result

When a bad phone number is passed in, it should be removed from the data and the service call made again, so that the bad phone number doesn't cause the whole call to fail.

Actual result

When a phone number without a country prefix (i.e. "+1") is passed in, the API returns a "bad phone number" message, but the pointer field doesn't have a value of "phone_number".

Example returned error JSON:

{
  "errors": [
    {
      "id": "6a679e76-11aa-456c-b53b-4541b00bf37e",
      "status": 400,
      "code": "invalid",
      "title": "Invalid input.",
      "detail": "The phone number provided either does not exist or is ineligible to receive SMS",
      "source": {
        "pointer": "/data"
      },
      "links": {},
      "meta": {}
    }
  ]
}

Additional information

The check on line 267 of utils.js doesn't allow the phone number to be removed in this instance, as the API call returns different data than is checked for.

Code in question:

if (session.custom.KLEmailSubscribe && emailListID) {
        data = {
            data: {
                type       : 'profile-subscription-bulk-create-job',
                attributes : {
                    list_id       : emailListID,
                    custom_source : 'SFCC Checkout',
                    subscriptions : [{
                        channels     : { email: ['MARKETING'] },
                        email        : email,
                        phone_number : phone
                    }]
                }
            }
        };

        result = klaviyoServices.KlaviyoSubscribeProfilesService.call(data);

        if (result == null) {
            logger.error('klaviyoServices.KlaviyoSubscribeProfilesService subscribe call for email returned null result');
        }

        if (!result.ok === true) {
            logger.error('klaviyoServices.KlaviyoSubscribeProfilesService subscribe call for email error: ' + result.errorMessage);
            // check to see if the reason the call failed was because of Klaviyo's internal phone number validation.  if so, resend without phone number
            var errObj = JSON.parse(result.errorMessage);
            if (result.error == 400 && errObj.errors[0].source.pointer == 'phone_number') {
                data.data.attributes.subscriptions[0].phone_number = null;
                result = klaviyoServices.KlaviyoSubscribeProfilesService.call(data);
                if (result == null) {
                    logger.error('klaviyoServices.KlaviyoSubscribeProfilesService subscribe call for email returned null result on second attempt without phone number');
                }
                if (!result.ok === true) {
                    logger.error('klaviyoServices.KlaviyoSubscribeProfilesService subscribe call for email on second attempt without phone number, error: ' + result.errorMessage);
                }
            }
        }
    }

Claire Test

Environment details

SiteGenesis or Storefront Reference Architecture:
Klaviyo Cartridge version:
Anything else that would help a developer reproduce the bug?

Steps to reproduce

  1. do smething
  2. do something else
  3. click the button

Expected result

Order is placed

Actual result

order was not placed

Additional information

No response

Test Issue for SFCC

Environment details

SiteGenesis or Storefront Reference Architecture:
Klaviyo Cartridge version:
Anything else that would help a developer reproduce the bug?

Steps to reproduce

  • do this
  • then that
  • and finally, that.

Expected result

Something expected

Actual result

something unexpected

Additional information

No response

Test Issue

Environment details

SiteGenesis or Storefront Reference Architecture:
Klaviyo Cartridge version:
Anything else that would help a developer reproduce the bug?

Steps to reproduce

TEST 1

Expected result

TEST 2

Actual result

TEST 3

Additional information

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.