Page 1 of 1

Updating order based on shipping method

PostPosted: Mon Oct 08, 2012 6:11 am
by info@.....com
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

Re: Updating order based on shipping method

PostPosted: Wed Oct 10, 2012 4:01 pm
by admin
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

Re: Updating order based on shipping method

PostPosted: Fri Oct 12, 2012 6:05 am
by info@.....com
hi stan,
That's very helpful, thanks!

Mike