Announcement

Collapse
No announcement yet.

Changing Shipping Class Option Value

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Changing Shipping Class Option Value

    Hi,

    I am attempting to find a way of passing a number to our shipping courier with each order depending on the shipping class a customer chooses. I have been thinking about the problem and decided the simplest way of solving it would be to pass this number to our courier in an unused field like the fax number text field (which would be hidden from the customer). This can then be sent to our courier via Mole Ends One Stop Order Processing order export.

    So what I am attempting to do is via a piece of javascript pass the value of the shipping option to this fax text field. What I could do with a hand with is getting each shipping class to have a unique value which corresponds to our courier companies shipping code. Therefore instead of our standard service having an option value of 10 I need it to have a value of 212.

    To do this I thought the easiest way would be to manually change the option value and I go into how this was attempted below. However if someone reads this and can think of a better method then I’m all ears. My other thoughts were to write a piece javascript which would look at the value of the currently selected option and then assign the correct value to the fax field, but this seemed a bit long winded.

    What I did:

    I am attempting to change each shipping classes value. By the value i mean the value set within the form on our site which corresponds to that class.

    i.e

    At present we have a couple of UK classes which look like below in the source code:

    <SELECT ID='lstClass' NAME='ShippingClass'>
    <OPTION Value='10'>Standard 1-3 days (£3.95)
    <OPTION SELECTED Value='12'>Next Working Day (£5.95)
    <OPTION Value='23'>Next Day pre 9.30am (£13.95)
    <OPTION Value='22'>Saturday Delivery (£19.95)
    </SELECT>

    however i need to change there values to ones which would correspond to a shipping service code provided by our courier Interlink express. Therefore i want the above source code to look like this:

    <SELECT ID='lstClass' NAME='ShippingClass'>
    <OPTION Value='210'>Standard 1-3 days (£3.95)
    <OPTION SELECTED Value='212'>Next Working Day (£5.95)
    <OPTION Value='234'>Next Day pre 9.30am (£13.95)
    <OPTION Value='16'>Saturday Delivery (£19.95)
    </SELECT>

    Within the ShipControl folder located in our site root folder there is a file called SimpleShipping.mdb and when opened in Access there is a table named Classes. After opening this I found that I could see the ClassID column the values of which correspond to the option values pasted in the first piece of source code above. The ClassID column is defined as an ‘autonumber’ field so I changed this to a number field so that I could manually edit the values for the shipping classes. I realise this will cause problems but I figured as long as I set up all my shipping classes now then I won’t need to add any more so it should be ok.

    Once I had changed these values to correspond with the values in the second piece of source code above I uploaded the site and found a number of problems.

    Firstly none of the value fields for the classes on the site have been changed ( i.e the standard 1-3 day service still reads like <OPTION Value='10'> not <OPTION Value='210'> as I wanted). Also none of the class names appear any longer (i.e Standard 1-3 days (£3.95) is now just displayed as (£3.95)). This obviously wasn’t the way to do this….

    All the names of the classes have also disappeared from view/business settings/Shipping and Handling but they actually function correctly on the site, by this I mean the prices still changes for each class depending on the weight you just have no idea what service you are selecting as you only see the price. It seems therefore that the ClassID field within SimpleShipping.mdb is only used to reference the name and description of a shipping class and assign it on the site.

    What I really need to know for this to work is what I need to update to be able to define my own values for all our shipping classes. If I then have to mirror these changes in the SimpleShipping.mdb file to get the names to display on the site that’s fine.

    This is of course unless someone knows of a much better way of doing this.
    Regards,

    Guy

    #2
    I imagine the changes aren't reflected on the website is because another table links in to the Classes table. I would have said that your initial suggestion of matching up the Actinic reference with your courier reference in the Javascript code was far better - it only has to be done once, and you'd still be able to modify your shipping settings via Actinic at a later date - as it is, you've broken the shipping table by changing the behaviour of the table's primary key.

    To achieve what you want in Javascript, I would use something like this:

    Code:
    function selectShippingBand(){
    var values={						// create an object with Actinic values as keys,
    	'10':210,					// pointing to your courier values
    	'12':212,
    	'23':234,
    	'22':16
    	};
    
    var band=document.getElementById('lstClass');		// get reference to the select box
    band=band.options[band.selectedIndex].value;		// get the selected value
    document.getElementById('fax').value=values[band];	// put the courier value into the fax field
    return true;
    }
    All you'd need to do is make this function run when the user clicks the 'Next' button (<form onsubmit='return selectShippingBand()'...>) and the right value will get submitted. Not really longwinded - this could be reduced to just 2 or 3 lines of code and means you won't have to mess around in Access when you need to adjust your shipping bands.
    www.gbradley.co.uk
    Web Development, Actinic Patches, Scripts & more

    Comment


      #3
      Hey Graham,

      Sorry it took me so long to get back but your script was a far better way to go and has worked a treat. Thanks alot pal
      Regards,

      Guy

      Comment


        #4
        If you want to do the above but use the OrderScript.pl to pass the info instead of javascript then take a look at the following thread http://community.actinic.com/showthread.php?t=28361

        Kind regards,
        Bruce King
        SellerDeck

        Comment

        Working...
        X