I'm using mini-cart to php to show the theory behind how this works. You can do this for many of the x-cart features, including customer information, $login variable, etc.
It's important to understand however, that the auth.php adds overhead, because it essentially initializes x-cart.
Definitely do not include auth.php more than once on a page. I've put the auth.php include inside this external_minicart.php, but if you are going to have several includes like this, you'll want to include auth.php only once per page and not in your includes.
This example is for 4.0.13
Create a new file, called exernal_minicart.php with the following code and substitue your full path for the auth.php include:
Code:
<?
require_once "/your/full/path/to/xcart/auth.php";
x_session_register ("cart");
$MINICART["total_cost"] = price_format(0);
$MINICART["total_items"] = 0;
$MINICART["sub_total"] = price_format(0);
if (!empty($cart)) {
if (!empty($cart["total_cost"]))
$MINICART["total_cost"] = $cart["total_cost"];
if (!empty($cart["subtotal"]))
$MINICART["subtotal"] = $cart["subtotal"];
if (!empty($cart["tax_cost"]))
$MINICART["tax_cost"] = $cart["tax_cost"];
if (!empty($cart["shipping_cost"]))
$MINICART["shipping_cost"] = $cart["shipping_cost"];
$MINICART["total_items"] = ((!empty($cart["products"]) and is_array($cart["products"]))?count($cart["products"]):0) + ((!empty($cart["giftcerts"]) and is_array($cart["giftcerts"]))?count($cart["giftcerts"]):0);
?>
<table border="0" cellpadding="2" cellspacing="2">
<tr>
<td>Items:</td>
<td><?= $MINICART["total_items"]; ?></td>
</tr>
<tr>
<td>Subtotal:</td>
<td><?= number_format($MINICART["subtotal"], 2, '.', ','); ?></td>
</tr>
<tr>
<td>Shipping:</td>
<td><?= number_format($MINICART["shipping_cost"], 2, '.', ','); ?></td>
</tr>
<tr>
<td>Tax:</td>
<td><?= number_format($MINICART["tax_cost"], 2, '.', ','); ?></td>
</tr>
<tr>
<td colspan="2">
<hr noshade size="1" color="#DBDBDB">
</td>
</tr>
<tr>
<td>Total:</td>
<td><?= number_format($MINICART["total_cost"], 2, '.', ','); ?></td>
</tr>
</table>
<?
} else {
echo "Your shopping cart is currently empty.";
}
?>
Include this file on any other php non-xcart page.