=== The Courier Guy Shipping for WooCommerce ===
Tags: ecommerce, e-commerce, woocommerce, shipping, courier
Requires at least: 4.9.8
Tested up to: 5.6.0
Requires PHP: 7.2
Stable tag: 4.3.5
License: GPLv3
License URI: https://www.gnu.org/licenses/gpl-3.0.html

This is the official WooCommerce extension to ship products using The Courier Guy.

== Description ==

The Courier Guy extension for WooCommerce enables you to ship products using The Courier Guy.

= Why choose The Courier Guy? =

The Courier Guy has built a strong reputation through strong customer relations and effective personal service. Today The Courier Guy is trusted, recognised and the fastest growing courier company in South Africa.

***DISCLAIMER***
Parcel sizes are based on your packaging structure. The plugin will compare the cart's total dimensions against "Flyer", "Medium" and "Large" parcel sizes to determine the best fit. The resulting calculation will be submitted to The Courier Guy as using the parcel's dimensions. By downloading and using this plugin, you accept that incorrect 'Parcel Size' settings may cause quotes to be inaccurate, and The Courier Guy will not be responsible for these inaccurate quotes.

== Installation ==

= MINIMUM REQUIREMENTS =
PHP 7.2 or greater is recommended.
MySQL 5.6 or greater is recommended.

WooCommerce 3.9.3 or greater is recommended.
Visit the [WooCommerce Plugin](https://wordpress.org/plugins/woocommerce/) page for more details.

A Courier Guy account.
Please ensure that your Courier Guy account has credit, if there is no credit in your Courier Guy account, then the plugin will not function correctly.
Visit the [The Courier Guy Website](https://www.thecourierguy.co.za/contact/) page for more details.

= AUTOMATIC INSTALLATION =
Automatic installation is the easiest option — WordPress will handle the file transfer, and you won’t need to leave your web browser. To do an automatic install of 'The Courier Guy Shipping for WooCommerce', log in to your WordPress dashboard, navigate to the Plugins menu, and click “Add New.”

In the search field type “The Courier Guy Shipping for WooCommerce,” then click “Search Plugins.” Once you’ve found the plugin, you can view details or click “Install Now”. WordPress should take it from there.

= MANUAL INSTALLATION =
Manual installation method requires downloading the 'The Courier Guy Shipping for WooCommerce' plugin and uploading it to your webserver via your favourite FTP application. The WordPress codex contains instructions on how to do this here.

= UPDATING =
Automatic updates should work smoothly, but we still recommend you back up your site.

= CONFIGURATION =

To configure your shipping, log in to your WordPress dashboard, navigate to the Woocommerce -> Settings menu, click the Shipping tab, and click “Add shipping zone.”

Fill out the form as follows, please also see the attached screenshots:

**Zone name**
The Courier Guy

**Zone regions**
Select regions as desired

**Shipping methods**
Click the 'Add shipping method', select 'The Courier Guy' from the available options and click 'Add shipping method'.

Now you can edit the newly created Shipping Method.

Fill out the form as follows, please also see the attached screenshots:

**Title**
The Courier Guy

**Account number**
The account number supplied by The Courier Guy for integration purposes.

**Tax status**
VAT applies or not

**Username**
The username supplied by The Courier Guy for integration purposes.

**Password**
The password supplied by The Courier Guy for integration purposes.

**Company Name**
The name of your company.

**Contact Name**
The name of a contact at your company.

**Shop Address1**
The address used to calculate shipping, this is considered the collection point for the parcels being shipping.

**Shop Address2**
The address used to calculate shipping, this is considered the collection point for the parcels being shipping.

**Shop Postal Code**
The address used to calculate shipping, this is considered the collection point for the parcels being shipping.

**Shop Phone**
The telephone number to contact the shop, this may be used by the courier.

**Shop Area / Suburb**
The suburb used to calculate shipping, this is considered the collection point for the parcels being shipping.
It is important to note that you will need to save the Shipping Method, with the correct 'Account number', 'Username' and 'Password' in order for this setting to auto-complete and populate the 'Shop Area / Suburb' options from The Courier Guy.

**Shop Town / City**
The suburb used to calculate shipping, this is considered the collection point for the parcels being shipping. This is the town/city used as the origin in the waybill.

**Exclude Rates**
Select the rates that you wish to always be excluded from the available rates on the checkout page.

**Percentage Markup**
Percentage markup to be applied to each quote.

**Automatically Submit Collection Order**
This will determine whether or not the collection order is automatically submitted to The Courier Guy after checkout completion.

**Ship internationally using other carriers**
When enabled, this will hide The Courier Guy 'Suburb/Area' when changing countries on the checkout page and will not make the field 'required'. If unsure, leave this disabled.

**Generic waybill description**
When enabled, a generic product description will be shown on the waybill.

**Price Rate Override Per Service**
These prices will override The Courier Guy rates per service.
Select a service to add or remove price rate override.
Services with an overridden price will not use the 'Percentage Markup' setting.

**Label Override Per Service**
These labels will override The Courier Guy labels per service.
Select a service to add or remove label override.

**Parcels - Flyer Size: Length of Flyer**
Length of the Flyer - required

**Parcels - Flyer Size: Width of Flyer**
Width of the Flyer - required

**Parcels - Flyer Size: Height of Flyer**
Height of the Flyer - required

**Parcels - Medium Parcel Size: Length of Medium Parcel**
Length of the Medium Parcel - optional

**Parcels - Medium Parcel Size: Width of Medium Parcel**
Width of the Medium Parcel - optional

**Parcels - Medium Parcel Size: Height of Medium Parcel**
Height of the Medium Parcel - optional

**Parcels - Large Parcel Size: Length of Large Parcel**
Length of the Large Parcel - optional

**Parcels - Large Parcel Size: Width of Large Parcel**
Width of the Large Parcel - optional

**Parcels - Large Parcel Size: Height of Large Parcel**
Height of the Large Parcel - optional

**Enable shipping insurance**
This will enable the shipping insurance field on the checkout page

**Enable free shipping**
This will enable free shipping over a specified amount

**Rates for free Shipping**
Select the rates that you wish to enable for free shipping

**Amount for free Shipping**
Enter the amount for free shipping when enabled

**Percentage for free Shipping**
Enter the percentage (shipping of product) that qualifies for free shipping when enabled. Zero to disable

**Enable free shipping from product setting**
This will enable free shipping if the product is included in the basket

**Suburb location**
Select the location of the Suburb field on checkout form.
The Suburb field will be displayed after the selected location.

**Suburb title**
Enter the title for the Suburb field.
This custom Suburb Title will be displayed on the checkout form.

**Enable WooCommerce Logging**
Check this to enable Monolog logging for this plugin.
Remember to empty out logs when done.

**Frequently Asked Questions**

= Does this require a Courier Guy account? =

Yes! A Courier Guy account is required. To open an account, please refer to [The Courier Guy](https://www.thecourierguy.co.za/contact/)

= Where can I get support or talk to other users? =

If you get stuck, you can ask for help in the Plugin Forum.

*Parcel Configuration and Accurate Quotes*
For accurate quotes to display, parcel dimensions for 'Flyer', 'Medium' and 'Large' parcels should be configured according to your needs. The algorithm will work out how many products will fit into each parcel, starting with the smallest size and working its way up. If you only have one or two parcel size (I.E. you don't use the flyer bag), dimensions of 1, 1, 1 can be used. All products will also need the correct dimensions and weights configured under their WooCommerce product settings.

*WCFM and WC Marketplace*
If this plugin is used together with the extension "WCFM and WC Marketplace - The Courier Guy Shipping for WooCommerce" it is possible to use vendor store addresses to override the base TCG shipping address
which is configured in the TCG shipping plugin.
To do this, from the Store Manager settings, select Store Vendors / Vendor / Details / Settings / Store Shipping.
Within the Store Shipping tab enable shipping and set processing time and shipping type. Then disable
shipping and update the settings. These steps are necessary for the vendor id to be passed to the shipping
module, and if it is not done, the default origin settings will be used.

*Product Settings*
There are three The Courier Guy specific settings in product settings
- Free Shipping - if enabled, a cart containing that product qualifies for free shipping
- Prohibit The Courier Guy - if enabled, TCG shipping will be disabled for that cart
 (both the above apply per vendor in the cart in a multi-vendor environment)
- Always pack as a single parcel - if enabled, each item of such a product will be a single parcel

== Changelog ==
= 4.3.4 - Jan 25, 2021
* Tested with WooCommerce 4.9.1 and Wordpress 5.6.
* Improve area/suburb field handing.
* Fix extra line added to WayBill.
* Change Monolog to the WooCommerce Logger.
* Don't stop checkout if shipping internationally.
* Improve product parcel calculations.
* Change the default flyer sizes.
* Add pool products capability.

= 4.3.3 - Nov 16, 2020
* Add cache buster.

= 4.3.2 - Nov 16, 2020
* Fix 'CRITICAL syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE)' issue.

= 4.3.1 - Nov 16, 2020
* Add 'Prohibit The Courier Guy' in product settings if cart contains this product.
* Add Shipping Selector feature.
* Fix consistent naming of session variable and general tidy-up.
* Pre-populate city area in billing.

= 4.3.0 - Oct 23, 2020
* PLEASE NOTE: If you use a multivendor platform, please test the integration thoroughly after updating.
* Fix SyntaxError: JSON Parse error: Unrecognized token ‘<.
* Fix undefined index warnings.
* Force cart reload in shipping field change.

= 4.2.9 - Oct 12, 2020
* Add option for single product per parcel at the product level.
* Add option to remove lowest cost quotes in multi vendor.
* Improve handling of failed POST requests to Parcel Perfect quotes.
* Fix TCG VAT total added when using free shipping feature.
* Fix free shipping bug in multi vendor plugin.
* Fix missing instance_id for some third party plugins.
* Remove use of cookies which caused failures on large orders and in multi vendor.
* Remove LOF Only Service.

= 4.2.8 - Sep 25, 2020
* PLEASE NOTE: Parcel sizes are based on your packaging structure. The plugin will compare the cart's total dimensions against "Flyer", "Medium" and "Large" parcel sizes to determine the best fit. The resulting calculation will be submitted to The Courier Guy as using the parcel's dimensions. By downloading and using this plugin, you accept that incorrect 'Parcel Size' settings may cause quotes to be inaccurate, and The Courier Guy will not be responsible for these inaccurate quotes.
* Amend shipping calculations to account for the entire order rather than individual line items.

= 4.2.7 - Sep 16, 2020
* Fix session_set error on some servers.
* Fix Invalid Product error for variable products.

= 4.2.6 - Sep 11, 2020
* Correct for index name changes in $package when using multivendor package.
* Simplify order shipping calculations and configuration.
* Remove product parcel settings.
* Remove global product quantity setting.
* Fix undefined index errors.
* Change payload calculation method for new sizes.
* Add customer phone on destpercell.

= 4.2.5 - Aug 25, 2020
* First try order meta to find shipping total, otherwise try the session, and if that fails, fallback to the cookie.
* Fix issue on guest checkout where the customer name was lost on waybill.

= 4.2.4 - Aug 12, 2020
* PLEASE NOTE: Print pending waybills before updating.
* Make insurance on checkout optional.
* Fix "An error of type E_ERROR".
* Remove old barcode and dompdf libraries.
* Show "Print Waybill" and "Send Order to Courier Guy" as appropriate.
* Add backup Cookie method if shipping missing from session.
* Fix "Undefined index: billing_insurance".
* Add option for generic product description on waybill.

= 4.2.3 - Aug 05, 2020
* Fix Call to undefined method ParcelPerfectApiPayload::factorise() if settings not configured.
* Improve ambiguous label "South Africa Only" -> "Ship internationally using other carriers".
* Waybill in email invalid if ‘collect from courier guy’ is not enabled.

= 4.2.2 - Jul 31, 2020
* Fix malformed number error.
* Use WC() session rather than $_SESSION to fix missing shipping information on orders.
* Fix null string issue.
* Add NFS service.
* Fix variable product calculations.
* Make shipping insurance on checkout optional.

= 4.2.1 - Jul 29, 2020
* Remove delivery date selection from checkout.

= 4.2.0 - Jul 25, 2020
* Add conditional free shipping feature.
* Add custom label and location for suburb area field.
* Fix shipment notifications.
* Fix parcel size, volume and weight calculations.
* Add parcel dimension configuration at both global and product levels.
* Add order id as WayBill reference.
* Add order notes for Parcel Perfect endpoint queries.
* Problem of variable products not calculating resolved with new methods.
* Adjust Waybill position and add clickable link in emails.
* Fix deprecated code warnings.
* Fix PHP missing index warnings.
* Fix collections submitted for the following day.
* Fix contact number is present where the name is supposed to go.
* Add option: If free shipping is active, remove all other shipping methods from checkout.
* Add option: Enable free shipping if selected products are in the cart.
* Add option: Enable free shipping if shipping total is a selected percentage of the total order value.
* Added VAT option for TCG shipping.

= 4.2.1 - November 28, 2020
* Change monolog to WC_Logger
