parcel4me / parcel4me
A one-click checkout and delivery package for PHP shopping carts
Requires
README
This package adds global one-click checkout and delivery to a PHP shopping cart using Parcel4Me.
It is a reusable un-opinionated interface that can be used with any existing PHP shopping cart.
Existing Implementations
These working implementations demonstrate how this Parcel For Me package can be used to intergrate Parcel For Me into an existing PHP Shopping Cart.
-
Bare-bones demo implementation
https://github.com/ParcelForMe/parcel4me-php-basedemo -
Wordpress Plugin "ParcelForMe for WooCommerce"
https://github.com/ParcelForMe/parcel4me-php-woocommerce -
Magento Plugin
https://github.com/ParcelForMe/parcel4me-php-magento
Installation
Add the package (↗)
$ composer require parcel4me/parcel4me
Tested working on PHP version 5.6.7.
Note: The updateCaCertificateIfChanged() method requires at least TLS v1.2 (for OpenSSL this means at least version 1.0.1)
Usage (how to modify an existing PHP shopping cart)
Implementation
To bring the Parcel4Me functionality into an existing shopping cart 3 steps are required :
-
Require the composer autoloader :
//require_once __DIR__.'/vendor/autoload.php';
require_once __DIR__.'/vendor/parcel4me/parcel4me/src/parcel4me/p4m-shop.php';
and implement the
P4M\P4M_Shop
abstract class, which means coding each of the methods listed inp4m-shop-interface.php
. -
add the Parcel4Me UI widgets into your shopping cart in the approprate places
(in the near future these will be available via a CDN) -
to accept all of the required
p4m/*
API endpoints :
(each of which has a corresponding function already implemented in the P4M_Shop)
API endpoints to receive on your router
p4m-login Widget
- GET p4m/getP4MAccessToken
- GET p4m/isLocallyLoggedIn
- GET p4m/localLogin
- GET p4m/restoreLastCart
p4m-checkout Widget
- GET p4m/checkout (or differently named endpoint)
- GET p4m/getP4MCart
- POST p4m/updShippingService
- GET p4m/applyDiscountCode
- GET p4m/removeDiscountCode
- POST p4m/itemQtyChanged
- POST p4m/purchase
- GET p4m/paypalSetup
- GET p4m/paypalCancel
- GET p4m/purchaseComplete
p4m-register Widget
- GET p4m/signup
About
This package implements the Host Server methods required by the Parcel4Me Widgets (See the documentation). It is implemented as an "Abstract Class" (and "Interface") package that can be used for connecting any PHP shopping cart.