where are the values

where are the values

Postby erb@.....com » Tue Feb 22, 2011 5:30 pm

Hello Stan

I can't get reduction and shipping values , your onepage is using my basket_b2c.html.php
in that page I have

displayRowResult(1 , $VM_LANG->_('PHPSHOP_CART_SUBTOTAL'), $subtotal_display);
displayRowResult($get_remise , $VM_LANG->_('PHPSHOP_REMISE_DISCOUNT'), $remise_display,1);
displayRowResult($discount_before , $VM_LANG->_('PHPSHOP_COUPON_DISCOUNT'), $coupon_display);
displayRowResult($shipping, $VM_LANG->_('PHPSHOP_ORDER_PRINT_SHIPPING'), $shipping_display);
displayRowResult(1 , $VM_LANG->_('PHPSHOP_ORDER_PRINT_TOTAL'), $order_total_display,1);

$subtotal_display is working fine but not the other values
in which file exactly do you get this values ? $shipping_display , $coupon ect ...

thank you
erb@.....com
 
Posts: 2
Joined: Sun Feb 20, 2011 1:23 pm

Re: where are the values

Postby admin » Wed Mar 02, 2011 10:38 am

This component can load your original basket.b2c.tpl.php or basket.b2b.tpl.php but also gives you an option in the configurator to use "basket override". It is all in one basket (b2c and b2b) where tax fields are shown dynamically according to tax configuration and it also can show shipping and/or payment inside basket updated on change. As standard basket loads as php file and has no ties on javascript when a shipping rate changes it cannot get updated. It is recommended to use "basket override" and customize its template to have all the features of the component. Overrided basket template is loaded from /components/com_virtuemart/themes/default/templates/onepage/overrides/basket.html.php
admin
Site Admin
 
Posts: 2708
Joined: Wed Jan 06, 2010 11:43 pm

Re: where are the values

Postby erb@.....com » Wed Mar 02, 2011 10:43 am

I have un-installed your extension, it works certainly well for a very basic VM installation, but it lacks flexibility for advanced utilization
erb@.....com
 
Posts: 2
Joined: Sun Feb 20, 2011 1:23 pm

Re: where are the values

Postby admin » Fri Mar 04, 2011 12:49 am

I am really sorry not being able to help even when i spent hours solving your modifications by email communication and I even provided you FTP access (for upload) to be able to work on this. Our component does as few hacks as possible in order to be easily installable, uninstallable and upgradable. Therefore if you have other modifications which are not "uninstallable" and are hard-coded in tens of your files and alter checkout process, coupon process we will have to merge them with our ps_onepage.php or optionally other files.

In general OPC is not recommended if
- you made hacks into shipping handling in ps_checkout and you use non-standard POST variable (other than shipping_rate_id) for saving the shipping
- you are using modifications which you did yourself and you cannot (or don't want) provide FTP access to let us make it compatible with your install
- you added a function to ps_checkout which instead of return values true/false does a redirect and is required for order processing

For everybody to understand if you want any extra variable which is depended on shipping to be shown on the checkout page you or us will need to edit every single file of onepage checkout. We are open and ready to make implementations which can be used on other customer's sites, but if your modification is used only at your site, you will have to buy "additional services" for us to help you with this.

The logic of the OPC is as follows:

1. shop.cart page loads basket.php
2. basket.php includes shiping file (ajaxhelper.php and shipping.php) which creates a variations of every shipping and payment incl. coupon and shows them in hidden input fields inline a special div
3. basket also loads your VM template files for listing payment methods, coupon code, user registration. This templates can be overriden when copied to OPC/overrides directory.
4. after shipping destination is changed, files ajaxhelper and shiping.php are loaded from javascript to get updated totals information and new list of shipping methods
5. javascript (onepage.js) updates totals (according to shipping fees and payment fees) and may set hidden input variables to be able to send them via POST on submit click

6. after submit button is clicked
ps_onepage is loaded insted of ps_checkout. The reason why we don't use ps_checkout (default order processing function in VM) is that it is using redirects and echo'es where it should use only logical return values such as true and false. We decided to incorporate any of your modifications in ps_checkout to our ps_onepage for free so you don't need to edit it for our component to work. It already has support for many custom modifications.

ps_onepage (main order saving file) has following logic:
- registers a user and logs him in if unlogged (registering a user is optional and can be turned off by joomla configuration) - uses own function shopper_add which is a modified version of ps_shopper->add(...
- adds shipping address (function add_shipto)
- validates input variables, shipping and payment fields (validate_add is a modified version ps_checkout->validate_add which return true or false instead of redirect to a checkout.index page)
- adds order (function addOrder which is a modified version of ps_checkout->add(
addOrder function stores all the POST variables which are being sent to other functions with $d variable. It can return true/false/5 where 5 is a problem with payment when a credit card payment cannot be validated. Most of the modifications to support external VM extensions such as Greek, UK and PayPal pro, AWO coupons, Italian coupons modifications were done inside this function to store the data as needed. This function calls ps_checkout functions with $thisch variable.

If you want to modify saving of the variables by your self, you can find helpfull these lines in addOrder function:
Code: Select all
// Collect all fields and values to store them in jos_vm_orders !
$fields = array( 'columnname' => $d['yourPOSTvariable'FROMtheBASKET'];, .... )


to save any custom field for a product you can also use $dboi->f('column_name_in_your_vm_product_table'); to access session variables you can use $_SESSION but remember to use serialization
Code: Select all
// here are the fields which are stored in jos_vm_order_item
// if you need to add any more you can do so here
$fields = array('order_id' => $order_id, 'yourCUSTOMproductFIELD'=>$d['yourPOSTvariable'] );


7. on sucess, the page is redirected to checkout.onepage which loads your default checkout.thankyou. On failture the customer is redirected back to shop.cart page.
admin
Site Admin
 
Posts: 2708
Joined: Wed Jan 06, 2010 11:43 pm

Re: where are the values

Postby dragos@.....ro » Tue May 03, 2011 3:01 pm

Hi,
I have made some changes in the script and I need some info from you. Our online store is shipping products from different warehouses, so when a user buys several products, the checkout displays him several shipping options for each package. Everything works well and we changed the onepage.js do display the sum of all shipping. The $vars became $vars[$i]. The problem is that we don't know how to pass the variables to ps_onepage.php. This file loads:
$fields = array(
'user_id' => $auth["user_id"],
'vendor_id' => $ps_vendor_id,
'order_number' => $order_number,
'user_info_id' => $d["ship_to_info_id"],
'ship_method_id' => @urldecode($d["shipping_rate_id"]),
'order_total' => $order_total,
'order_subtotal' => $order_subtotal,
'order_tax' => $order_tax,
'order_tax_details' => serialize($order_tax_details),
'order_shipping' => $order_shipping,
'order_shipping_tax' => $order_shipping_tax,
'order_discount' => $payment_discount, );

The issue is that order_subtotal is 0 and in the mysql table nothing is written in the shipping fields. How do you pass this variables from ajax to ps_onepage.php?
Do you use session variables? If so why do you build the hidden inputs that store shipping and payment information?

I would much appreciate your help.

You can see the script working on www.wonderbaby.ro

Have a nice day.
dragos@.....ro
 
Posts: 1
Joined: Tue May 03, 2011 2:32 pm

Re: where are the values

Postby admin » Fri May 06, 2011 2:06 pm

Hello, there are several ways to do this, but don't use session is it is not stable when using AJAX as it loads in different thread (connection).

Shipping can be firstly manipulated by files in
/components/com_onepage/shipping/ajaxhelper.php and shipping.php

If you want to send a value to ps_onepage, you need to create an hidden input box such as in your template file, or add it to $op_formvars in basket.php (be carefull to have it included in both unlogged and logged templates)

In the template file this has to be inside main form tag, which can be checked by viewing the source.
<input type="hidden" name="op_yournewitem" value="" id="op_yournewitem" />

and then anywhere in the appropriate section in onepage.js you can call javascript to change the value as:

var myval = document.getElementById('op_yournewitem');
myval.value = "your actual value which will be sent to ps_onepage. ";

NOTE: we are not using mootools as we want to guarantee as much compatibility as possible

Anywhere in ps_onepage you can use $d['op_yournewitem'] to get the value. The function which saves and handles the order saving mechanism is addOrder(&$d) where $d is used by reference, which means that if you change it anywhere in the code, it will be changed for any other function which follows in the same connection untill redirect.

Some of the data are saved by first fetching table column names, creating an empty array for these columns and than issueing an insert command to the table. This is done due to many extensions using an additional table columns in standard VM tables. Firstly these values are searched in $d['column_name'] and then in $_SESSON[' ... This is however not done for every single table in ps_onepage yet.

In the following days we are going to create a new feature for Onepage checkout:
1. There will be a file called extension.php with these functions
2. renderHtml : this function will show age verificatioon and ask for personnal data such as national ID filtered only to certain products (for example guns according to EU regulations)
2.1: ajaxJavascriptOnChange, ajaxJavascriptOnBlur, ajaxJavascriptOnFocus : php functions to process data on the fly
3. renderJavascript: this function will return javascript used to verify data in (2) after clicking submit button, but before the form is submitted
4. beforeUserRegistration(&$d) where $d are all the POST variables from the checkout section, here we can move personal data to session variable and delete it from POST
5. afterUserRegistration(&$) : this will be used to change shopper_group_id for a feature such as when user's total purchases are larger than x amount
6. beforeOrderSave(&$d): here we will add code from external payment modules which need to do a database operations before saving orders
7. afterOrderSave(&$d): for cleaning purposes of any credit card data which are not normally cleaned by virtuemart
8. beforeEmailSent(&$d) : this function will be able to alter standard email sending feature, for example if it returns false the standard email will not be sent
9. getEmailHtml : will be used to show a HTML in your email if $_SESSION is found for shopper who purchased guns
9. afterEmailSent : cleaning $_SESSION variables

This feature is ordered by one of our customers and will be implemented in next several days.

We also want to create asynchronious afterOrderProcessing which can call APIs for external sites. This will be called by a system plugin which will detect a new order on each page view (we think that this is better way then cron way). Asynchronious order processing can be used for tasks which would normally take too much time to load after submitting the order and could cause timeout or other errors. It will be mainly used for
- PDF creation for our API
- SMS sending to customers or shop owners
- price comparison companies if you need to notify them of an order

Normally each external call with curl or file_get_contents on an external domain takes from 1 to 6 seconds. Therefore this has to be done asynchroniously.

Regards,
Stan
admin
Site Admin
 
Posts: 2708
Joined: Wed Jan 06, 2010 11:43 pm


Return to One Page Checkout for Virtuemart 1.1.x

cron