I am retrieving the vat value from my form:
Would make a difference if the form i'm retrieving it from displays the information to the customer before they click the confirm button and bring them to the third party's website.
The only way I know to try to help you is to get back to the basics of what you are trying to do. You have an order form on which the user can enter several items, each for a different product and a qty. You want to store these records first as a shopping cart, then collect them and add shipping cost and perhaps VAT, depending on total order amount, then store the records, including an order record, to a different table, including the shipping cost and VAT. Is that correct?
The above is correct.
My tables are as follows:
Code: Select all
CREATE TABLE `tbl_order` (
`od_id` int(10) unsigned NOT NULL auto_increment,
`member_username` varchar(30),
`od_date` datetime default NULL,
`od_last_update` datetime NOT NULL default '0000-00-00 00:00:00',
`od_status` enum('New', 'Paid', 'Shipped','Completed','Cancelled') NOT NULL default 'New',
`od_memo` varchar(255) NOT NULL default '',
`od_shipping_first_name` varchar(50) NOT NULL default '',
`od_shipping_last_name` varchar(50) NOT NULL default '',
`od_shipping_address1` varchar(100) NOT NULL default '',
`od_shipping_address2` varchar(100) NOT NULL default '',
`od_shipping_phone` varchar(32) NOT NULL default '',
`od_shipping_city` varchar(100) NOT NULL default '',
`od_shipping_state` varchar(32) NOT NULL default '',
`od_shipping_postal_code` varchar(10) NOT NULL default '',
`od_shipping_cost` decimal(5,2) default '0.00',
`od_vat` int(2) NOT NULL default '21',
`od_payment_first_name` varchar(50) NOT NULL default '',
`od_payment_last_name` varchar(50) NOT NULL default '',
`od_payment_address1` varchar(100) NOT NULL default '',
`od_payment_address2` varchar(100) NOT NULL default '',
`od_payment_phone` varchar(32) NOT NULL default '',
`od_payment_city` varchar(100) NOT NULL default '',
`od_payment_state` varchar(32) NOT NULL default '',
`od_payment_postal_code` varchar(10) NOT NULL default '',
PRIMARY KEY (`od_id`,`member_username`)
) TYPE=MyISAM AUTO_INCREMENT=1310 ;
CREATE TABLE `tbl_order_item` (
`od_id` int(10) unsigned NOT NULL default '0',
`pd_id` int(10) unsigned NOT NULL default '0',
`od_qty` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`od_id`,`pd_id`)
) TYPE=MyISAM;
CREATE TABLE `tbl_cart` (
`ct_id` int(10) unsigned NOT NULL auto_increment,
`pd_id` int(10) unsigned NOT NULL default '0',
`ct_qty` mediumint(8) unsigned NOT NULL default '1',
`ct_session_id` char(32) NOT NULL default '',
`ct_date` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`ct_id`),
KEY `pd_id` (`pd_id`),
KEY `ct_session_id` (`ct_session_id`)
) TYPE=MyISAM AUTO_INCREMENT=58 ;
Now, if that is correct, the next thing to determine is where you want to calculate VAT and add shipping cost; presumably when you are ready to write the total order. So where is the VAT going to come from? Somehow it doesn't seem appropriate to be coming from your form--your customer shouldn't be involved in this step. Does it need to come from a table, such as relating VAT to levels of purchase? If not, why wouldn't you just code the percentage in your script? I understand that it needs to be stored in the final order, but I don't see any need to be passing it in the $_POST variable array, nor indeed why ANY of the data for the final order should be coming from a form. Shouldn't it just be taking the data that's already stored in the shopping cart and moving it into the final order records?? That's why I'm very confused about your project.
I've tried to just add $vat = 21; but the 3rd parties does not accept it for some reason. But if i used a $_POST it'll accept it. Quite weird after i tested it. Not sure how that is. The shpping cart is 3 php scripts away from where the vat and shipping cost needs to be sorted in checout-functions.php so i don't think you can take it from the shopping cart. i may be wrong.
Edit: Oh, maybe you are displaying the final order to your customer for verification! That would make sense. So you will need to display the VAT calculation at that time, in the form. Is that what you are doing?
thats correct, thats what i'm doing.
This is the shopping cart i'm using. I'm trying to not use Paypal but a different 3rd party.
http://www.phpwebcommerce.com/php-mysql ... torial.php