Download the PHP package cartboss/cartboss-php without Composer

On this page you can find all versions of the php package cartboss/cartboss-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package cartboss-php

Requirements

To use CartBoss SDK, the following things are required:

Composer Installation

By far the easiest way to install the CartBoss SDK is to require it with Composer.

$ composer require cartboss/cartboss-php:^2.0

{
    "require": {
        "cartboss/cartboss-php": "^2.0"
    }
}

Before you begin

Please take a few minutes to learn about basic CartBoss concepts.

1. Events

CartBoss is an event based service. Our SDK includes everything you need to build, validate and send events to CartBoss either in "real-time" or from your backend.

1.1. AddToCart event

AddToCart event occurs when visitor leaves your site without placing an order. It is up to you to decide when this makes sense for your case, but most common implementation is to send AddToCart event every time visitor updates one of the checkout fields (eg. First name, Phone, Cart items, ...).

AddToCart event is then processed by CartBoss and a queue of abandoned cart messages for provided phone number is created at our end. If there's no following Purchase event received, CartBoss will start sending messages accordingly to your abandoned cart automation setup.

It's perfectly fine to send multiple AddToCart events for same order.

1.2. Purchase event

Purchase event occurs when visitor places an order. Purchase event is very similar to AddToCart event, with an addition of CartBoss Attribution token (explained below).

When CartBoss receives Purchase event for particular order, all remaining messages from abandoned cart sequence are destroyed and never sent. If enabled, a new post-purchase sequence is created.

Because of this, it is very important to make sure you send Purchase event for all "completed" orders from your backend (eg. cronjob). Basic implementation would include adding a new boolean field send_cartboss_purchase to your order table with default value set as false, updated to true once order is placed.

2. URL Interceptors

Most text messages (SMS) sent by CartBoss to your contacts contain an urls that take them back to your site when clicked.

CartBoss "communicates" with your site through a few special URL query parameters prefixed with "cb__". With the help of CartBoss SDK you can easily access intercepted values through registered listeners.

2.1. Attribution Interceptor

CartBoss's Attribution token (cb__att) is a 64char hash injected into all urls pointing to your site. It helps CartBoss to distinct between organic and CartBoss-based purchases. Your main objective is to intercept, store and pass attribution token to Purchase event once order is successfully placed.

Example urls with Attribution Token injected:

2.2. Discount Interceptor

CartBoss's Discount token (cb__discount) is an encrypted and urlencoded array of three values (type|code|value). It enables you to send dynamic offers to your visitors (eg. Hi Mike, order now and get 20% OFF of your entire order. Click here ).

Example urls with Discount Token injected:

Discount interceptor validates, decodes and returns valid Coupon object if discount is provided through SMS message.

Example implementation

Our code includes Example project which can be found at this link Example project. In case you need additional help, please contact us.

Getting started

1. Initializing CartBoss SDK

Initialize CartBoss SDK library with your API key. It is recommended to initialize CartBoss SDK and register URL interceptors on each request and as early as possible in your code.

2. Registering Attribution interceptor

Every time Attribution token is intercepted and pushed to your implementation of onAttributionIntercepted() method, it's advised to store it into session/cart/order/database for later use, as you're going to attach it to Purchase event later on.

3. Registering Discount interceptor

Every time Discount token is intercepted and pushed to your implementation of onCouponIntercepted() method, you should insert a new coupon (if it doesn't already exist) to your database and attach it to visitor's cart/order/session.

4. Sending AddToCart event

AddToCart event is usually sent, whenever new checkout information is available. For example; when visitor enters a phone number, sets first name, or updates delivery country...

There are two very important aspects to keep in mind:

Minimal AddToCart event example. You can find full example at event_atc.php.

5. Restoring abandoned cart

Each abandoned cart text messages includes shortened url (checkout_url) back to your website. URL is provided through a method setCheckoutUrl() with AddToCart event. This handler must be publicly accessible and able to restore visitors old session within a new browser.

Implementation of this script is up to your business logic, but in abstract implementation, it should do the following:

  1. parse url parameter for order_id
  2. fetch order from your local database
  3. check if order exists and is still in "abandoned" state
  4. store order_id to visitors session
  5. redirect to your checkout page (along with utm_ params)
  6. otherwise, redirect visitor to your home page

You can find example cart restore script at cart_restore.php.

6. Sending Purchase event

Purchase event is sent once the order has been placed on your store. It is highly suggested sending these events from your backend eg. 1min cronjob.

Minimal Purchase event example. You can find full example at event_purchase.php.

FAQ

Q: What happens when AddToCart event is sent to CartBoss?
A: A queue of abandoned cart text messages is created for provided phone number - usually one to three texts.

Q: When does CartBoss stop sending abandoned cart texts?
A: When a Purchase event with same $order->setId() as AddToCart event is received, or all texts from the queue have been sent out.

Q: What happens if I don't provide attribution token with Purchase event?
A: Such event will not count towards CartBoss statistics, as it's considered as organic conversion.

Q: What is checkout_url I have to send with AddToCart event?
A: An URL that is sent to your visitor to restore session/cart in a new mobile browser.

Q: Should I send a Purchase event for every purchase made on our site - organic and CartBoss based?
A: Yes

Q: What should I don if sending an event fails?
A: You can simply ignore AddToCart errors, but should do your best to deliver all Purchase events.

Helpers

We provide a few helper methods to ease your CartBoss SDK integration.

PHP

Please see for available helper functions.

JS

Please see CartBossJS for more info. jQuery required.


All versions of cartboss-php with dependencies

PHP Build Version
Package Version
Requires php Version >=7.3
ext-curl Version *
ext-json Version *
ext-mbstring Version *
ext-openssl Version *
composer/ca-bundle Version ^1.3
delight-im/cookie Version ^3.4
guzzlehttp/guzzle Version ^7.4
rakit/validation Version ^1.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package cartboss/cartboss-php contains the following files

Loading the files please wait ....