CartThrob Multi Address Shipping Version 1.1
With Multi-Address shipping, you'll be able to capture multiple addresses for your customers whether they are logged in, or guests. You can group items in the cart by address, you can allow customers to add and update unlimited addresses as well, and specify a default address. Each item that's added to the the cart with an address will display that address in its post-order line-item for easy reference, and you can group items post-order in your notifications by address as well. Also, each order's costs will be calculated separately, there's no limit to the number of addresses set per person.
Features
- Works with guests and members alike
- Easy setup. No channels required
- Group items by address
- Group items by address in notifications
- Addresses are saved per line-item in orders for easy reference
- You can add arbitrary data, as well as standard address info (to capture things like notes, and shipping instructions)
Requirements
- ExpressionEngine 2.5+
- CartThrob 2.2+
- PHP 5.3+
Installation
- Upload the
/system/expressionengine/third_party/cartthrob_multi_shipto/
folder to/system/expressionengine/third_party/
- Make sure Extensions are enabled on your system
- Install the CartThrob Multi Shipto module and extension (through EE's add-ons/modules panel)
Upgrading
- Upload the
/system/expressionengine/third_party/cartthrob_multi_shipto/
folder to/system/expressionengine/third_party/
Overwriting existing files. - Go to [EE] settings » addons » and click "Run Module Updates"
Tags
address_form
Works with existing customer info. Uses standard CartThrob customer info variables.
if no address id parameter is set in this form, the default information will be output by default. if last
is specified as the address id, it will use the last recipient added. if new_recipient
is specified as the address id, it will add a new recipient when the form is created in this way, you can ajax submit an item to the cart, and load a template immediately after with the last created user, or you can just display the latest added address on another page.
If a new recipient is added with no nickname, Address 1, Address 2, etc will be added as the nickname for the address.
Variables
address_id
The address id
nickname
The nickname of this address
All customer_info
variables
Any customer info variable like {customer_last_name} {customer_first_name} {customer_address} {customer_shipping_address} will output inside this tag loop.
Parameters
address_id
The address_id
that you'd like to edit. This value can also be set in the form itself using the address_select
tag
return
When this form is submitted, this is where the customer will be redirected to.
additional parameters
All CartThrob global standard variables are compatible with this form tag.
Example
{exp:cartthrob_multi_shipto:address_form return="multi_shipto/items" address_id="new_recipient"}
<h3>Customer Info</h3>
Edit Existing: {exp:cartthrob_multi_shipto:address_select new_recipient="yes" address_id="{address_id}"}<br>
<br>
nickname <input type="text" value="{nickname}" name="nickname" /> <br>
<br>
first_name <input type="text" value="{customer_first_name}" name="first_name" /> <br>
<br>
last_name <input type="text" value="{customer_last_name}" name="last_name" /> <br>
<br>
address <input type="text" value="{customer_address}" name="address" /> <br>
<br>
address2 <input type="text" value="{customer_address2}" name="address2" /> <br>
<br>
city <input type="text" value="{customer_city}" name="city" /> <br>
<br>
state {exp:cartthrob:state_select name="state" selected="{customer_state}" add_blank="yes" }<br>
<br>
zip <input type="text" value="{customer_zip}" name="zip" /> <br>
<br>
country {exp:cartthrob:country_select name="country_code" selected="{customer_country_code}"}<br>
<br>
company <input type="text" value="{customer_company}" name="company" /> <br>
<br>
phone <input type="text" value="{customer_phone}" name="phone" /> <br>
<br>
email_address <input type="text" value="{customer_email_address}" name="email_address" /> <br>
<br>
<h3>Shipping Info</h3>
shipping_first_name <input type="text" value="{customer_shipping_first_name}" name="shipping_first_name" /> <br>
<br>
shipping_last_name <input type="text" value="{customer_shipping_last_name}" name="shipping_last_name" /> <br>
<br>
shipping_address <input type="text" value="{customer_shipping_address}" name="shipping_address" /> <br>
<br>
shipping_address2 <input type="text" value="{customer_shipping_address2}" name="shipping_address2" /> <br>
<br>
shipping_city <input type="text" value="{customer_shipping_city}" name="shipping_city" /> <br>
<br>
shipping_state {exp:cartthrob:state_select name="shipping_state" selected="{customer_shipping_state}" add_blank="yes" } <br>
<br>
shipping_zip <input type="text" value="{customer_shipping_zip}" name="shipping_zip" /> <br>
<br>
shipping_country {exp:cartthrob:country_select name="shipping_country_code" selected="{customer_shipping_country_code}"} <br>
<br>
shipping_company <input type="text" value="{customer_shipping_company}" name="shipping_company" /> <br>
<br>
shipping_phone <input type="text" value="" name="shipping_phone" /> <br>
<br>
shipping_email_address <input type="text" value="" name="shipping_email_address" /> <br>
<br>
<h3>Other Options</h3>
Is this your default address? <input type="checkbox" value="1" name="default_address" /> <!-- this will only be assigned to ONE --> <br>
<br>
Delete this address? <input type="checkbox" value="1" name="delete" /> <br>
<br>
gift_wrap <input type="checkbox" value="1" name="gift_wrap" /> <br>
<br>
gift_note <input type="text" value="" name="gift_note" /> <br>
<br>
shipping_option {exp:cartthrob:get_shipping_options} <br>
<br>
<h3>You can capture any additional fields too per address, and output them. </h3>
additional arbitrary field <input type="text" value="{pets_name}" name="pets_name" /> <br>
<input type="submit" name="Submit" />
{/exp:cartthrob_multi_shipto:address_form}
address_select
This generates a dropdown select of addresses.
Parameters
new_recipient
Whether to show the new recipient option or not.
new_recipient="yes"
address_id
This is the address that should be preselected
address_id="{address_id}"
row_id
If the item is in the cart, you should specify the row_id
. The select will output in the correct syntax for udpate_cart_form
and will preselect the correct address_id
.
name
Name of the field. Generally you don't need to set this, as it's output automatically. Use this only if you want to override the default behavior
id
CSS id
class
CSS class
onchange
Javascript onchange
extra
Additional items like:
extra="rel='something' title='my title' "
Example
Adding an item to cart with an address specified
{exp:cartthrob:add_to_cart_form
price="10"
on_the_fly="yes"
return=""
entry_id="{entry_id}"
}
{exp:cartthrob_multi_shipto:address_select new_recipient="yes" param="1"}
<input type="submit" value="Add to Cart" />
{/exp:cartthrob:add_to_cart_form}
Updating an item in the cart
{exp:cartthrob:cart_items_info}
{exp:cartthrob:update_cart_form return="" }
{!-- add the row id, so that this will update this specific item --}
{exp:cartthrob_multi_shipto:address_select new_recipient="yes" row_id="{row_id}"}
<input type="submit" value="Update Cart" />
{/exp:cartthrob:update_cart_form}
{/exp:cartthrob:cart_items_info}
Updating an address
{exp:cartthrob_multi_shipto:address_form return="multi_shipto/items"}
<h3>Customer Info</h3>
Edit Existing: {exp:cartthrob_multi_shipto:address_select new_recipient="yes" address_id="{address_id}"}<br>
<br>
nickname <input type="text" value="" name="nickname" /> <br>
<br>
first_name <input type="text" value="" name="first_name" /> <br>
{/exp:cartthrob_multi_shipto:address_form}
grouped_items
This outputs items grouped by address in the cart, or once an order has been completed and the cart has been cleared.
Variables
row_id
This is a pipe delimited list of row_ids
. If an order_id is passed, then this is related to the row_ids
of the order items. If no order id is passed, this will be referencing line items in the cart.
entry_ids
This is a pipe delimited list of entry_ids
.
nickname
The nickname of the address
address_id
The address id
group_total
The total amount of the current group of items
group_quantity
The number of items in this group
All customer_info
variables
Any customer info variable like {customer_last_name} {customer_first_name} {customer_address} {customer_shipping_address} will output inside this tag loop.
Parameters
order_id
This is the order's entry id.
order_id="{entry_id}"
Example
Viewing items grouped by address
{exp:cartthrob_multi_shipto:grouped_items}
<h3>{nickname}</h3>
{customer_first_name} {customer_last_name} <br>
Total: {group_total}<br>
Number of items: {group_quantity}
<br><br>
{exp:cartthrob:cart_items_info row_id="{row_ids}"}
{title} {price}<br>
{/exp:cartthrob:cart_items_info}
<br><br><br>
{/exp:cartthrob_multi_shipto:grouped_items}
Viewing items grouped by address in a completed order
{exp:cartthrob:submitted_order_info}
<h2>Viewing Grouped Order Items</h2>
{if authorized}
{exp:cartthrob_multi_shipto:grouped_items order_id="{entry_id}"}
<h3>{nickname}</h3>
{customer_first_name} {customer_last_name} <br>
Total: {group_total}<br>
Number of items: {group_quantity}
<br><br>
{shipping}
{row_ids} {entry_ids}
<table>
{!-- use the row_id parameter to get at specific row items. the rest is standard order items code. --}
{exp:cartthrob:order_items order_id="{entry_id}" row_id="{row_ids}" }
<tr class="{item:switch="odd|even"}">
<td><span style="font-size:12px;">{item:entry_id}</span></td>
<td><span style="font-size:12px;">
{item:title}
{if is_package}
<p>
<span style="font-size:9px;">
{packages}
{sub:title}<br />
{/packages}
</span>
</p>
{/if}
</span></td>
<td align="right"><span style="font-size:12px;">{item:quantity}</span></td>
<td align="center"> </td>
<td align="right"><span style="font-size:12px;">{item:price}<br />(w/ tax: {item:price_plus_tax})</span></td>
<td align="right">
<span style="font-size:12px;">
{item:subtotal}<br />(w/ tax: {item:subtotal_plus_tax})
</span>
</td>
<td align="right">
{if item:product_download_url}
<span style="font-size:12px;"><a href="{exp:cartthrob:get_download_link field='product_download_url' entry_id='{item:entry_id}'}">Download</a></span>
{/if}
</td>
</tr>
{/exp:cartthrob:order_items}
</table>
<br><br><br>
{/exp:cartthrob_multi_shipto:grouped_items}
{if:elseif declined}
Your credit card was declined: {error_message}
{if:elseif processing}
Your payment is currently being processed. We will contact you when the processing has completed: {error_message}
{if:elseif failed}
Your payment failed: {error_message}
{/if}
{/exp:cartthrob:submitted_order_info}
[ee]: http://expressionengine.com/index.php?affiliate=mahuti