Hello;
I'm using an advanced theme (markettheme) with a shopping cart included.
The problem is that the shopping cart is displayed inside a "thickbox" using javascript and CSS and I don't like that way.
It's easy to exclude the thickbox css, but the problem is that the shopping cart is displayed in a clean web page (no css of the theme no header, no sidebar, no footer).
So the question is: How to include the header/sidebar/footer in the shopping cart php file?
The shopping cart module is located in a specific folder inside the theme folder. And the way to call (link) this shopping cart from a simple button is:
<li><a href="<?php bloginfo('template_directory'); ?>/ajCart/cart.php?cart=true&height=220&width=600&CARTDIR=<?php bloginfo('template_directory'); ?>/ajCart/&PPEmail=<?php bloginfo('admin_email'); ?>" class="thickbox" title="Shopping Cart" >Shopping Cart</a></li>
I'm very newbie with php but I've been trying:
<?php get_header(); ?>
and
include("../header.php");
inside cart.php (the main php file of the module, and cart-top.php) unsuccesfully
It could be really nice if somebody can help me with this,
Thank you very much,
from Madrid,
Roy
Post Data:
If it could be helpfull, this is the code of cart.php:
<?php
session_start();
require("config.php");
//location of the cart directory
if($_GET["CARTDIR"]){
$CARTDIR=$_GET["CARTDIR"];
unset($_GET["CARTDIR"]);
}else{
$CARTDIR="http://www.markettheme.com/demo/wp-content/themes/mk3/ajCart/";
}
$CARTURL = $CARTDIR."cart.php";
//Paypal Email
if($_GET["PPEmail"]){
$PPEmail=$_GET["PPEmail"];
unset($_GET["PPEmail"]);
}else{
$PPEmail="youremail@yourdomain.com";
}
//TODO: Create Cart Object
$crtQuantity = array();
$crtAmount = array();
$crtShipping = array();
$crtShipping2 = array();
$crtHandling = array();
$crtHandlingCart = array();
$crtOptions = array();
$PPOptions = array();
//retrieve session Variables
if($_SESSION["Quantity"]){
$crtName = $_SESSION["Name"];
$crtQuantity = $_SESSION["Quantity"];
$crtAmount = $_SESSION["Amount"];
$crtShipping = $_SESSION["Shipping"];
$crtShipping2 = $_SESSION["Shipping2"];
$crtHandling = $_SESSION["Handling"];
$crtHandlingCart = $_SESSION["HandlingCart"];
$crtOptions = $_SESSION["Options"];
$PPOptions = $_SESSION["PPOptions"];
}
//convert strings to integers
function str2int($string, $concat = true) {
$length = strlen($string);
for ($i = 0, $int = '', $concat_flag = true; $i < $length; $i++) {
if (is_numeric($string[$i]) && $concat_flag) {
$int .= $string[$i];
} elseif(!$concat && $concat_flag && strlen($int) > 0) {
$concat_flag = false;
}
}
return (int) $int;
}
//Save Session Variables
function SaveSession($crtName,$crtAmount,$crtQuantity,$crtShipping,$crtShipping2,$crtHandling,$crtHandlingCart,$crtOptions,$PPOptions=' '){
$_SESSION["Name"] = $crtName;
$_SESSION["Quantity"] = $crtQuantity;
$_SESSION["Amount"] = $crtAmount;
$_SESSION["Shipping"] = $crtShipping;
$_SESSION["Shipping2"] = $crtShipping2;
$_SESSION["Handling"] = $crtHandling;
$_SESSION["HandlingCart"] = $crtHandlingCart;
$_SESSION["Options"] = $crtOptions;
$_SESSION["PPOptions"] = $PPOptions;
}
//Monolithic display cart function
function ShowCart($crtName,$crtAmount,$crtQuantity,$crtShipping,$crtShipping2,$crtHandling,$crtHandlingCart,$crtOptions,$PPOptions){
include("cart_top.php");
global $CARTURL;
$checkout = '';
$i = 1;
foreach( $crtAmount as $item =>$amount ){
$Shipping = 0;
if ($crtShipping[$item]){
$Shipping = $crtShipping[$item];
if ($crtQuantity[$item] > 1){
$Shipping += $crtShipping2[$item] * ($crtQuantity[$item] - 1 );
}
$checkout .='<input type="hidden" name="shipping_'.$i.'" value="'.$Shipping.'" />';
}
$Shipping = 'Shipping: €'.$Shipping;
$content .= '<tr id="'.$item.'"><td>'.$crtName[$item].'</td><td>'.$crtOptions[$item].' '.$Shipping.'</td><td><input class="quantity" name="'.$item.'" type="text" value="'.$crtQuantity[$item].'" /></td><td><a href="'.$GLOBALS["CARTURL"].'?remove='.$item.'" class="crtRemove">Remove</a></td><td>€'.(float)($crtAmount[$item] * $crtQuantity[$item]).'</td></tr>';
if ($crtHandling[$item]){
$Handling = $crtHandling[$item];
if($crtQuantity[$item] > 1){
$Handling += $crtHandlingCart[$item] * ($crtQuantity[$item] - 1);
}
$checkout .='<input type="hidden" name="handling_'.$i.'" value="'.$Handling.'" />';
}
$checkout .='<input type="hidden" name="item_name_'.$i.'" value="'.$crtName[$item].'" />
<input type="hidden" name="amount_'.$i.'" value="'.$crtAmount[$item].'" />
<input type="hidden" name="quantity_'.$i.'" value="'.$crtQuantity[$item].'" />';
$tmp = explode("",$crtOptions[$item]);
$itr=0;
foreach ($tmp as $chk){
if($chk!=""){
list($opt,$val)=explode(":",$chk);
$checkout.='<input type="hidden" name="on'.$itr.'_'.$i.'" value="'.$opt.'" /><input type="hidden" name="os'.$itr.'_'.$i.'" value="'.$val.'" />';
}
++$itr;
}
//$checkout.=sprintf($PPOptions[$item],$i);
++$i;
}
include("cart_bottom.php");
echo $content;
}
if($_GET['cart']){
ShowCart($crtName,$crtAmount,$crtQuantity,$crtShipping,$crtShipping2,$crtHandling,$crtHandlingCart,$crtOptions,$PPOptions);
}
if($_GET["remove"]){
$item = $_GET["remove"];
unset($crtName[$item]);
unset($crtAmount[$item]);
unset($crtQuantity[$item]);
unset($crtShipping[$item]);
unset($crtShipping2[$item]);
unset($crtHandling[$item]);
unset($crtHandlingCart[$item]);
unset($crtOptions[$item]);
SaveSession($crtName,$crtAmount,$crtQuantity,$crtShipping,$crtShipping2,$crtHandling,$crtHandlingCart,$crtOptions,$PPOptions);
}
if($_GET["update"]){
foreach ($_GET as $item => $value ){
if($crtQuantity[$item]){
$crtQuantity[$item] = str2int($value);
}
}
SaveSession($crtName,$crtAmount,$crtQuantity,$crtShipping,$crtShipping2,$crtHandling,$crtHandlingCart,$crtOptions,$PPOptions);
ShowCart($crtName,$crtAmount,$crtQuantity,$crtShipping,$crtShipping2,$crtHandling,$crtHandlingCart,$crtOptions,$PPOptions);
}
if($_GET["add"]){
$item ="item".rand();//An Id can be used in lue of store with multiple items with the same name
$name = $_GET["item_name"];
$amt = (float)$_GET["amount"];
$handling = (float)$_GET["handling"];
$handling_cart = (float)$_GET["handling_cart"];
$quan = str2int($_GET["quantity"]);
$ppoptions = "";
$options = "";
$i = 0;
if(strpos($_GET["shipping"],"/")){
$ar = explode("/",$_GET["shipping"]);
$ship = (float)$ar[0];
$ship2= (float)$ar[1];
}else{
$ship = (float)$_GET["shipping"];
$ship2= 0;
}
foreach ($_GET as $key => $value ){
$val = substr($key,0,2);
if($val=="on"){
$opt = substr($key,2,1);
$index = "os".$opt;
$options.= $value.':'.$_GET[$index].'';
/*Removed for testing
$ppoptions.='<input type="hidden" name="'.$key.'_%1$d" value="'.$value.'" />';
$ppoptions.='<input type="hidden" name="'.$index.'_%1$d" value="'.$_GET[$index].'" />';
*/
++$i;
}
}
if($crtQuantity[$item]){// Is item in the array already?
$crtQuantity[$item] += $quan;
if($crtShipping[$item] < $ship){
$crtShipping[$item] = $ship;
$crtShipping2[$item] = $ship2;
$crtHandling[$item] = $handling;
$crtHandlingCart[$item] = $handling_cart;
}
}else{// A new item
$crtName[$item] = $name;
$crtAmount[$item] = $amt;
$crtShipping[$item] = $ship;
$crtShipping2[$item] = $ship2;
$crtHandling[$item] = $handling;
$crtHandlingCart[$item] = $handling_cart;
$crtQuantity[$item] = $quan;
$crtOptions[$item] = $options;
$PPOptions[$item] = $ppoptions;
}
//Save the Session and Display the cart
SaveSession($crtName,$crtAmount,$crtQuantity,$crtShipping,$crtShipping2,$crtHandling,$crtHandlingCart,$crtOptions,$PPOptions);
ShowCart($crtName,$crtAmount,$crtQuantity,$crtShipping,$crtShipping2,$crtHandling,$crtHandlingCart,$crtOptions,$PPOptions);
}
?>