Webshop Plus! v.2.0 for WWB7

This forum is dedicated to discussions about shopping carts/ecommerce.
Forum rules
PLEASE READ THE FORUM RULES BEFORE YOU POST:
viewtopic.php?f=12&t=1901
gp2727
 
 
Posts: 134
Joined: Fri Nov 04, 2005 12:40 pm
Location: USA

Post by gp2727 » Wed Feb 04, 2009 1:54 am

Thanks Navaldesign......Your skills are greatly appreciated....... 8) 8) 8) :D :D :D

User avatar
Navaldesign
 
 
Posts: 1003
Joined: Sat Mar 01, 2008 8:08 pm
Location: Italy
Contact:

Post by Navaldesign » Wed Feb 11, 2009 5:21 am

It is obvious that EITHER the pages have not been published as php, OR for some reason your host doesn't parse them as such.

None of the above "strange" texts would appear if the script worked ok.

To embed the autorize.net checkout, you will need to add the necessary code (similarly to what is done for PayPal).
www.dbtechnosystems.com

User avatar
Navaldesign
 
 
Posts: 1003
Joined: Sat Mar 01, 2008 8:08 pm
Location: Italy
Contact:

Post by Navaldesign » Sun Feb 22, 2009 6:28 am

The code that creates the Order ID is:

Code: Select all

// create unique order id
$orderid = strtotime("now").$_SERVER['REMOTE_ADDR']; 
$orderid = str_replace(".", "", "$orderid"); 
You can find it in the "thankyou" page Start of Page code.

The Order ID consists of the time (Linux time, seconds since 31 Dicember 1969), in this one 1235269773 combined with your IP address 76.107.196.252 (without dots).

So as you see it is a logical pattern.

However, you can change ALL of the Start of Page code with the following one:


Code: Select all


<?php 
session_start();

ini_set('display_errors', 1);
error_reporting(55);

require 'admin/config.php';
require 'admin/paypal_settings.php';

define("PRODUCTCODE", 0);
define("PRODUCTNAME", 1);
define("QUANTITY", 2);
define("PRICE", 3);

$itemcount = isset($_SESSION['itemcount']) ? $_SESSION['itemcount'] : 0;
if ($itemcount == 0)
{
   header("Location: "."error.php?msg=".rawurlencode("Please add items to your shopping cart before checking out."));
   exit;
} 

if (!isset($_SESSION['email']))
{
   header("Location: "."error.php?msg=".rawurlencode("We did not find your information, please fill the needed information again."));
   exit;
} 

$paymenttype = $_SESSION['paymenttype'];

// create unique order id
$alpha = "Order nr. "; 
$order_start = "100"; 
$dbts_file_name = "order_nr.php"; 

if (!file_exists($dbts_file_name)) { 
$orderid = $order_start; 
} 
else{ 
include $dbts_file_name; 
} 

$orderid++; 

$dbts_file_name = "order_nr.php"; 


$dbts_values  = "<? \n"; 

$dbts_values .= '$orderid='; 
$dbts_values .= "\"$orderid\";\n"; 

$dbts_values .= '?>'; 

if(file_exists($dbts_file_name)) 
{ 
unlink ($dbts_file_name); 
} 
if (!$dbts_handle = fopen($dbts_file_name, 'a+')) { 
   header("Location: "."error.php?msg=".rawurlencode("Cannot open Order Details file.")); 
   exit; 
} 


if (fwrite($dbts_handle, $dbts_values) === FALSE) { 
   header("Location: "."error.php?msg=".rawurlencode("Cannot write Order Details file.")); 
   exit; 
} 
fclose($dbts_handle); 


// get timestamp for this order
$timestamp = date("Y-m-d H:i:s");

// create mail message to customer
$subject = "Your order with $dbts_title"; 
$title = "Thank you for your order!";
SendEmail($_SESSION['email'], $subject, $title, $orderid, $timestamp, true);

// create mail message to merchant
$subject = "Order confirmation for $dbts_title";
$title = "The message is sent for your records of a purchase.  Please review the purchase below, and fulfill as necessary.";
SendEmail($dbts_contactemail, $subject, $title, $orderid, $timestamp, false);

function SendEmail($mailto, $subject, $title, $orderid, $timestamp, $maskcardno)
{
   $header  = "From: ".$GLOBALS['dbts_title']."<".$GLOBALS['paypal_email'].">"."\r\n"; 
   $header .= "Reply-To: $paypal_email"."\r\n"; 
   $header .= "MIME-Version: 1.0"."\r\n"; 
   $header .= "Content-Type: text/plain; charset=utf-8"."\r\n"; 
   $header .= "Content-Transfer-Encoding: 8bit"."\r\n"; 
   $header .= "X-Mailer: PHP v".phpversion(); 

   $message = $title."\r\n"."\r\n";
   $message .= $GLOBALS['alpha']." $orderid \r\n"; 
   $message .= "Order Date: ".$timestamp."\r\n"."\r\n";
   $message .= "Customer info:"."\r\n";
   $message .= "Firstname: ".$_SESSION['firstname']."\r\n";
   $message .= "Lastname: ".$_SESSION['lastname']."\r\n";
   $message .= "Email: ".$_SESSION['email']."\r\n";
   $message .= "Address: ".$_SESSION['address']." - ".$_SESSION['address2']."\r\n";
   $message .= "City: ".$_SESSION['city']."\r\n";
   $message .= "Zip: ".$_SESSION['zip']."\r\n";
   $message .= "State: ".$_SESSION['state']."\r\n";
   $message .= "Country: ".$_SESSION['country']."\r\n";
   $message .= "Phone: ".$_SESSION['phone']."\r\n"."\r\n";

   $message .= "Shipping address:"."\r\n";
   $message .= "Name: ".$_SESSION['shipname']."\r\n";
   $message .= "Address: ".$_SESSION['shipaddress']."\r\n";
   $message .= "City: ".$_SESSION['shipcity']."\r\n";
   $message .= "Zip: ".$_SESSION['shipzip']."\r\n";
   $message .= "State: ".$_SESSION['shipstate']."\r\n";
   $message .= "Country: ".$_SESSION['shipcountry']."\r\n";

   $message .= "Payment info:"."\r\n";
   $message .= "Type: ".$_SESSION['paymenttype']."\r\n";
   if ($maskcardno)
   {
      $message .= "Credit Number: ".substr($_SESSION['cardno'],0,4)."..."."\r\n";
   }
   else
   {
      $message .= "Credit Number: ".$_SESSION['cardno']."\r\n";
   }
   $message .= "Card Name: ".$_SESSION['cardname']."\r\n";
   $message .= "Card Expires: ".$_SESSION['cardmonth']."/".$_SESSION['cardyear']."\r\n"."\r\n";

   $message .= "Ordered items:"."\r\n";
   $message .= "Code"."\t"."Item"."\t"."No."."\t"."Price"."\r\n";
   $message .= "======================================================="."\r\n";

   $itemcount = $_SESSION['itemcount'];
   $cart = $_SESSION['cart'];

   $total = 0;
   for ($i=0; $i<$itemcount; $i++)
   {
      $message .= $cart[PRODUCTCODE][$i]."\t";
      $message .= $cart[PRODUCTNAME][$i]."\t";
      $message .= $cart[QUANTITY][$i]."\t";
      $message .= $currency.number_format($cart[PRICE][$i]*$cart[QUANTITY][$i],2)."\r\n";
      $subtotal = $subtotal + ($cart[PRICE][$i]*$cart[QUANTITY][$i]);
   }

   $message .= "======================================================="."\r\n";
   $message .= "Net Total: $currency_symbol".number_format($_SESSION['subtotal'],2)."\r\n";
   $message .= "======================================================="."\r\n";
   $message .= "Shipping: $currency_symbol".number_format($_SESSION['shipping'],2)."\r\n";
   $message .= "======================================================="."\r\n";
   $message .= "Order Grand Total: $currency_symbol".number_format(($subtotal + $_SESSION['shipping']),2)."\r\n";
   $message .= "\r\n"."\r\n";

   mail($mailto, $subject, stripslashes($message), $header); 
}

?>
How does the code work?

It creates an order ID consisting of the alphanumeric part (Order nr. ) plus a autoincrement index (starting from 101).

If you wish you can replace the alphanumeric part with anything else (Example: "Cute Cart Order nr. " ) and the starting order nr ( Example: 201 ).

After each order, the code also stores the Order nr so next time an order is placed, it increases it by 1.
Last edited by Navaldesign on Mon Feb 23, 2009 7:14 am, edited 2 times in total.
www.dbtechnosystems.com

User avatar
Navaldesign
 
 
Posts: 1003
Joined: Sat Mar 01, 2008 8:08 pm
Location: Italy
Contact:

Post by Navaldesign » Mon Feb 23, 2009 6:37 am

I will come back to you later, after testing the code and embedding it in the "webshop_plus".
www.dbtechnosystems.com

User avatar
Navaldesign
 
 
Posts: 1003
Joined: Sat Mar 01, 2008 8:08 pm
Location: Italy
Contact:

Post by Navaldesign » Mon Mar 02, 2009 10:31 pm

A REALLY majoR update has been made: Tax categories, promo Codes, Mail customization, and Language change without editing a single line of code.

The entire customization process now is made in the administration interface AND in WB5 . You don't need to change anything at all in the code, anymore.

Please read the updated First Post in this thread.
www.dbtechnosystems.com

User avatar
me.prosenjeet
 
 
Posts: 1281
Joined: Mon Dec 24, 2007 1:50 pm
Location: Lucknow
Contact:

Post by me.prosenjeet » Wed Mar 11, 2009 2:36 pm

I am trying to lay my hand for the first time on the shopping cart.
I want to put only two products.
Is it ok if I delete the pages product 3 and 4?
Will it disturb any settings?
Do I need to add/delete/edit any code on the other pages?
Sorry for novice question but,then this is my first try...bear with me :D
.
Click here to check my Pro WB Extensions
Click here to check my Pro WB Templates
---------------------------------------------------------
www.Lucknowwebs.com
---------------------------------------------------------

User avatar
Navaldesign
 
 
Posts: 1003
Joined: Sat Mar 01, 2008 8:08 pm
Location: Italy
Contact:

Post by Navaldesign » Wed Mar 11, 2009 3:23 pm

You may add or delete as many product pages as necessary. The demo project is just an example, so it is coming with 1 main (catalog type) and 4 subpages for products, but for your own cart you can do whatever necessary.
www.dbtechnosystems.com

User avatar
Navaldesign
 
 
Posts: 1003
Joined: Sat Mar 01, 2008 8:08 pm
Location: Italy
Contact:

Post by Navaldesign » Mon Apr 20, 2009 8:04 pm

powelli wrote:Hi, just to two quick questions re, this shopping cart. At the cart.php page can I replace the contiune shopping button to the push button, and set the events to java, on click, history go back. As I have several products page I would prifer this rather than the link to prodcts page.
Yes, BUT unless this is simply a "Back" button, put this button outside the cart form limits, as usually events will conflict with the form submission.

Also when a discount code is enterd to the cart, it just emptys the whole cart, I have not changed the code at all just the layouts on the pages, if I upload all the admin files for the cart again would this affect my cart at all the work I have done, such as layouts and products etc?
Many thanks
Owain
Uploading the admin files again might result in getting a different look for the table colors and fonts etc. But, you can take a backup of the file "config.php" and upload it again.

However, thsi issue has nothing to do with the Admin interface, most probably it is something you have done wrong in your pages.
www.dbtechnosystems.com

User avatar
Navaldesign
 
 
Posts: 1003
Joined: Sat Mar 01, 2008 8:08 pm
Location: Italy
Contact:

Post by Navaldesign » Tue Apr 21, 2009 4:57 pm

joewhite wrote:Hello Navaldesign!

Thanks for you new cart, was waiting for this. Just what i was looking for. just have 2 questions for you.

1.) Can I have multiple options for a product? like for red shirt (+$10) and XXL (+$3) ?

2.) I uploaded the new cart but i get this error:

Warning: main(admin/config.php): failed to open stream: No such file or directory in /var/www/html/carttest/cart.php on line 7

How can I fix this?


Thanks friend
1. Yes, you can. You can also have, for the same option, price affecting and NON price affecting values (Example: Small, Medium and Large NOT price affecting, Extra Large and XXL price affecting)

2. If you had NOT installed the cart previously, you need to do so. Which means that you need to create a folder named "admin" and upload in there all the files that are contained in the "admin" folder of the zip. Then log in in your administration area to setup the cart according to your needs.
www.dbtechnosystems.com

User avatar
Navaldesign
 
 
Posts: 1003
Joined: Sat Mar 01, 2008 8:08 pm
Location: Italy
Contact:

Post by Navaldesign » Tue Apr 21, 2009 7:21 pm

Sorry, but i don't understand, can you please post a link to the project you published ? If you look at http://www.dbtechnosystems.com/wb5/cart1/product1.php
you will see that i have setup two dropdowns (price affecting options are Macos and Linux for the OS and Italian for the language).
www.dbtechnosystems.com

User avatar
Navaldesign
 
 
Posts: 1003
Joined: Sat Mar 01, 2008 8:08 pm
Location: Italy
Contact:

Post by Navaldesign » Tue Apr 21, 2009 8:43 pm

Hi,

I'm not sure what you tried to do by copying / pasting the same dropdowns. Further more, you kept the same names for the dropdowns!
Also, you did NOT add a hidden field for each option! Please read again the instructions (first post of this thread) as to HOW you add options in your Add to Cart forms:

Please understand that by placing the same dropdowns twice, you only receive the values of one for each pair (As would happen with ANY form field that has the same name as another one).
And, as said, you need to setup, for each option dropdown, a hidden field with the option name.

Double click the form in the "product1" page, go in "Hidden Fields" and see that there are two hidden fields, one named :

"option_name1" with value "OS" (Operating system) and the other

"option_name2" with value "Language"
www.dbtechnosystems.com

User avatar
Navaldesign
 
 
Posts: 1003
Joined: Sat Mar 01, 2008 8:08 pm
Location: Italy
Contact:

Post by Navaldesign » Wed Apr 22, 2009 5:40 am

1. It doesn't take the third option because you have mistaken the third option dropdown name. It is "options_values3" instead of the "correct option_values3" . Remove the "s" you have added.

2. Seems to me quite stange that you need more than 8 options, 99% of the users will not even need more than two or three.

Anyway, to change this you can change the code in the "cart" page.

You will see a line that looks like this:

for ($opt = 1; $opt <= 8; $opt++){


Change "8" to whatever you need.
www.dbtechnosystems.com

User avatar
Navaldesign
 
 
Posts: 1003
Joined: Sat Mar 01, 2008 8:08 pm
Location: Italy
Contact:

Post by Navaldesign » Wed Apr 22, 2009 8:05 am

Look at the code in the Start of Page of the page HTML:

function AddToCart()
{
$cart = isset($_SESSION['cart']) ? $_SESSION['cart'] : '';
$itemcount = isset($_SESSION['itemcount']) ? $_SESSION['itemcount'] : 0;

$productname = $_POST['productname'];
$extra_price = 0;
for ($opt = 1; $opt <= 8; $opt++){
$key = 'option_name'.$opt;
$key1 = 'option_values'.$opt;
$option_name = trim($_POST[$key]);
$option_value = trim($_POST[$key1]);

if ($option_value != "") {
unset($options);
$options = explode(",", $option_value);
$productname .= " / $option_name : ".$options[0];
$extra_price = $extra_price + $options[1];
}
}
$productname = stripslashes($productname);
www.dbtechnosystems.com

User avatar
Navaldesign
 
 
Posts: 1003
Joined: Sat Mar 01, 2008 8:08 pm
Location: Italy
Contact:

Post by Navaldesign » Wed Apr 22, 2009 8:50 am

1. Unlimited
2. You would need to use Javascript or Ajax, but that exceeds the limits of this free cart, so you first have to add it in th ecart to see the price.
www.dbtechnosystems.com

User avatar
Navaldesign
 
 
Posts: 1003
Joined: Sat Mar 01, 2008 8:08 pm
Location: Italy
Contact:

Post by Navaldesign » Sun Apr 26, 2009 1:17 pm

Update April 26, 2009:

Added possibility to perform shipping charges calculations based on total products weight, using a hidden field to declare each product's weight (just like the price etc) .

Added possibility to perform shipping charges calculations based on individual item shipping cost, using a hidden field to declare each product's shipping charges.

Updated the Administrator Interface to allow for the new options
www.dbtechnosystems.com

Post Reply