Updating order based on shipping method

Updating order based on shipping method

Postby info@.....com » Mon Oct 08, 2012 6:11 am

Hi,
We need to make some changes to information displayed on the OPC checkout page (and to the order itself) based on the shipping method that the user selects. Specifically, we will calculate the expected delivery date base don the shipping method they select.

I'd be grateful if you could advise the best place to insert our code to do this? I see that changeTextOnePage() in onepage.js checks the shipping method when it is changed (although it returns a hash, rather than a readable shipping method). Would we be best updating this?

Thanks!

Mike
info@.....com
 
Posts: 6
Joined: Sun Jun 24, 2012 2:27 pm

Re: Updating order based on shipping method

Postby admin » Wed Oct 10, 2012 4:01 pm

Hello Mike, if you need to send any sort of data to the ajax generated html code of the shippin methods you can do so within ajaxhelper.php file. The OPC1 includes several triggeres.

If you are looking for a triggerer "after shipping method selected" please have a look onto extension in /components/com_onepage/ext/paymentpershipping

to trigger a javascript function, just add this code anywhere within body tags (within the theme files for example):
Code: Select all
<script type="text/javascript">
  if ((typeof callAfterShippingSelect != 'undefined') && (callAfterShippingSelect != null))
  callAfterShippingSelect.push("yourFunction()");
</script>

(you can add cdata tags as well)

within yourFunction(), you can use:
Code: Select all
selectedshipping = getVShippingRate();


which will return VM1 format of the shipping method's data.
or getInputIDShippingRate() which will return an ID -> but be carefull as some methods can share the same id for more then one method (ups...)

you can then make tests with
Code: Select all
if (selectedshipping.indexOf('what_i_am_looking_for')>=0)
{
  // create an element with <div id="delivery_date_here">&nbsp;</div>
  document.getElementById('delivery_date_here').innerHTML = 'anything you want to show to the customer';
}


Within OPC1 i decided not to use mootools or jquery due to the compatiblity with all of the j1.5 themes.

To include external javascript file, please check include.php within your theme in
/components/com_virtuemart/themes/default/templates/onepage/YOUR SELECTED THEME/include.php


You also may want to check the delivery date extensions for OPC1 at the extension tab -> usr_act and others.

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

Re: Updating order based on shipping method

Postby info@.....com » Fri Oct 12, 2012 6:05 am

hi stan,
That's very helpful, thanks!

Mike
info@.....com
 
Posts: 6
Joined: Sun Jun 24, 2012 2:27 pm


Return to One Page Checkout for Virtuemart 1.1.x

cron