Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

insaini

Pioneers
  • Posts

    207
  • Joined

  • Last visited

Posts posted by insaini

  1. Hi Everyone

     

    Not sure if anyone else is having this problem but i have installed the latest v1.5.5 and i believe everything is working except for the fact that when you select a country the states change corresponding to the country but the default selection is the most bottom of state in the pull down menu.

     

    How do i change it so that the first selection is the state on the top of the state pull down menu and not the bottom?

     

    I had noticed this as well.. I have not looked into yet.. but i have noticed it.. im not sure exactly why its doing that yet..

  2. Hi Jesse,

     

    I'm almost there, I have it copying over customer details and changing the country, but the state isn't changing.

     

    Can you spot what I've missed?

     

    Dave

     

    Well what you are trying to do in your javascript is copy billing_states.value to shipping_states.value. This isnt possible. The name of the SELECT drop down for each states dropdown for both billing and shipping is 'zone_id' or 'state' if there are no zones.. both have the same form name.. the only way to reference each of them is the way i said to above.. by getting the DIV element and then going to its node with is the select element.. that is the only way to get to them in order to get their values..

     

    However I have just realized another problem which I didnt see before.. when someone submits this form.. you are only going to get one zone_id or one state value to your process. You need to two of course.. there is only one way that I can see to do this.. and that is modifying the original ajax function and adding a name parameter and then the way you have your javascript now should be just fine to work.. this is probably the easier way..

     

    you can change the function in catalog/includes/functions/ajax.php to

     

    	function ajax_get_zones_html($name, $country, $default_zone = '', $ajax_output = true) {
    	$output = '';
    
    	$zones_array = array();	
    	$zones_query = tep_db_query("select zone_id, zone_name from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "' order by zone_name");
    	while ($zones_values = tep_db_fetch_array($zones_query)) {
    		$zones_array[] = array('id' => $zones_values['zone_id'], 'text' => $zones_values['zone_name']);
    	}
    
    	if ( tep_db_num_rows($zones_query) ) {
    		$output .= tep_draw_pull_down_menu($name.'_zone_id', $zones_array,$default_zone);	  
    	} else {
    		$output .= tep_draw_input_field($name.'_state',$default_zone);
    	}  
    	if (tep_not_null(ENTRY_STATE_TEXT)) $output .= ' <span class="inputRequirement">' . ENTRY_STATE_TEXT;			
    
    	if ($ajax_output) {
    		header('Content-type: text/html; charset='.CHARSET);
    		echo $output;
    	} else {
    		return $output;
    	}
    }

     

    As you can see from the code change above $name is appended to the front of _zone_id or _state .. so when you change the code by adding the name "billing" or "shipping" to the states dropdown code.. the javascript variable will be "billing_zone_id" or "shipping_zone_id" you will have to make the changes in your process function to $_GET['billing_zone_id'] and not just $_GET['zone_id'] ..etc..

     

    everything else should be ok.. I hope this makes sense?

     

    J

  3. Thanks for the help again, it's much appreciated.

     

    I realise this is getting sort of off topic and i don't know if you would be prepared to help any further, no worries if you don't.

     

    I've got as far as i can at the moment but I'm getting an error that one of the values is null. On the old state selector the values were names in the form e.g, echo tep_draw_input_field('states'); and then called in the javascript by code like form.shipping_states.value = form.states.value;

     

    but this doesn't appear to work any more.

     

    Any ideas?

     

    Thanks

     

    Dave

     

    those names are still there.. infact they are exactly the same.. but there is no way to directly reference them .. in order to get to them.. you have to go through the DIV that surrounds the states dropdown..

     

    you have to reference the DIV .. and then loop through the nodes of the DIV ... (there is only one node so its not like it will loop for a long time.. the only node is a SELECT element) this is your states dropdown.. you can then see which of these is selected and copy it over.. its a little more coding to your javascript function..

     

    					  <td class="main"><div id="states">
    					  <?php
    			// +Country-State Selector
    			echo ajax_get_zones_html($country,'',false);
    			// -Country-State Selector
    			?>
    					</div></td>

     

    see the <div id="states"> you should have two of them.. because you have two dropdowns.. they should also be renamed to "billing_states" and "shipping_states"

     

    in the javascript code you would reference them like this

     

    		var _div = getObject("billing_states");
    
    	for (i=0; i<_div.childNodes.length; i++){
    		if (_div.childNodes[i].nodeName=="SELECT") {
    			_div.childNodes[i].focus(); // this is what you would use in your custom code would go. You can now get the id and name of the billing_states dropdown box which is selected .. and copy it over to the "shipping_states" but getting that dropdown in the same manner.. 
    					} 
    	}

  4. Jesse,

     

    on the original (un-ajaxed version) the form elements have names which the javascript uses to copy across to the shipping address

     

    e.g.

    	if (count($zones_array) > 1) {
      echo tep_draw_pull_down_menu('zone_id', $zones_array);
    } else {
      echo tep_draw_input_field('state');
    }

     

    In your ajax verssion there is just

     

    <div id="states">						  
    <?php				
    // +Country-State Selector
    echo ajax_get_zones_html($country,'',false);
    // -Country-State Selector
    ?>
    </div>

     

    Any ideas on how I would go about copying the entry/selection made?

     

    Thanks

     

    Dave

     

    p.s the existing code i have in the form_check.js is to copy that entry

     

    if(form.shipzone_id) {
    shipzone_id = form.zone_id.value;
    }
    else {
    shipstate = form.state.value;
    }

     

     

    when you duplicate the code for your shipping address section.. you need to rename the DIV element id parameter for both states drop-downs..

     

    name the first one to "billing_states" and second to "shipping_states"

     

    you will probably also need to change the name of the country drop-down boxes for both ..

     

    once thats done.. in the javascript code that you have.. when the customer clicks same as billing or whatever.. you can reference the billing states and countries easily.. for the states first you need to use the getObject function ie...getObject('billing_states') .. and use that to loop to the select element contained in it.. from there you can get the states values .. next you can also simply reference the country in basically the same manner.. although I dont think you need to use getObject ..

     

    in either case you will need to modify that custom javascript function you have in order to copy that info over the shipping country-state boxes..

  5. oops sorry,

     

    I've just upload the correct files and get a different error :)

     

    You also have to make the change I show above your last post..

     

    AND

     

    in your create_account45.php .. where it has the country dropdown code..

     

    you have

     

    onChange="getStates(this.value, this.form, 'states');

     

    you have to change that to

     

    onChange="getStates(this.value, 'states');

     

    the latest contribution gets rid of the requirement for this.form

     

    J

  6. Dave.. I just accessed your link create_account45.php

     

    and it still shows the old javascript code.. are you sure you updated the changes to your server?

     

    this is the javascript code that is showing up at this link http://www.dirtbikebitz.com/create_account45.php

    function getStatesRequest() {
    var next = false;
    if (request.readyState == 4) {
    	// make hidden
    	getObject('indicator').style.visibility = 'hidden';
    	getObject("states").innerHTML = request.responseText;
    	  document.account.state.focus();			
    }
    }

     

    it SHOULD be from the latest contribution.. try updating to the code changes from the latest contribution.. overwrite your existing catalog/includes/ajax.js.php and catalog/includes/functions/ajax.php and make the change necessary to your create_account45.php file and I can test it again..

     

    J

     

     

    Oh and another thing I just realized.. because you are making the modifications to create_account45.php

     

    you also need to update the function

    function getStates(countryID) {   
    if (request.readyState == 4 || request.readyState == 0) {
    	// indicator make visible here..
    	getObject("indicator").style.visibility = 'visible';
    	var contentType = "application/x-www-form-urlencoded; charset=UTF-8";
    	var fields = "action=getStates&country="+countryID;
    
    	request.open("POST", 'create_account.php', true);
    	request.onreadystatechange = getStatesRequest;
    	request.setRequestHeader("Content-Type", contentType);		
    	request.send(fields);
    }
    }

     

    located in catalog/includes/ajax.js.php

     

    see where it says create_account.php you need to change that ... change it to <?php echo basename($PHP_SELF); ?> .. i think that may be the actual problem

     

    so basically change it from

    		request.open("POST", 'create_account.php', true);

     

    to

    		request.open("POST", '<?php echo basename($PHP_SELF); ?>', true);

     

    J

  7. Dave.. I just accessed your link create_account45.php

     

    and it still shows the old javascript code.. are you sure you updated the changes to your server?

     

    this is the javascript code that is showing up at this link http://www.dirtbikebitz.com/create_account45.php

    function getStatesRequest() {
    var next = false;
    if (request.readyState == 4) {
    	// make hidden
    	getObject('indicator').style.visibility = 'hidden';
    	getObject("states").innerHTML = request.responseText;
    	  document.account.state.focus();			
    }
    }

     

    it SHOULD be from the latest contribution.. try updating to the code changes from the latest contribution.. overwrite your existing catalog/includes/ajax.js.php and catalog/includes/functions/ajax.php and make the change necessary to your create_account45.php file and I can test it again..

     

    J

  8. Just to follow up, here's the word back from GoDaddy re: cURL support:

     

    Chris, it may work on 7.16 .. I can't say for sure..the most important thing is that curl is built with openssl .. the way you can verify this is by going to admin -> tools -> server info ..

     

    scroll to curl and see how its been built (it should include openssl at least v0.97)

     

    you can also see if it works by commenting out step 3 to step 10 in ship_canadapost_ajax.php

     

    case 1:
    break;
    case 2:
    break; /*
    case 3:
    break;
    ..
    case 10:
    break; */
    default:
    break;

     

    comment out case 3 to case 10 .. if when you click submit it displays "Logged In" for step 2 .. then you know it will work.

     

    J

  9. @insaini: It will be nice if you add/update the country state selector ajax addon on a weekly basis. if you have around 4 version updates in a day for every small thing, it becomes difficult to keep it updated. It will also be helpful if you add upgrade documents to each version update. When doing on a weekly basis it will also save your precious time.

     

    just my 2 cents.

     

    I understand... but updating on a weekly basis when a product that undergoes many revisions in one day is kinda pointless dont you think? Most of the changes were minor missed things.. at 1.5.5 i feel its all been taken care of ..

     

    as for upgrade documents.. it the reason why I didnt include any from 1.5 to 1.5.5 is really the changes are at most 3 lines of code with 2 replaced files...

     

    the new files from a new installation.. just over-write (ajax files) and then the 3 lines of code modified.. just compare the changes from a manual new install to your current files.. dont think its that difficult .. imo

  10. finally if that doesnt work..

     

    try changing the getObject function in ajax.js.php

     

    to this

     

    function getObject(name) { 
      var ns4 = (document.layers) ? true : false; 
      var w3c = (document.getElementById) ? true : false; 
      var ie4 = (document.all) ? true : false; 
    
      if (ns4) return document.layers[name]; // eval('document.' + name); 
      if (w3c) return document.getElementById(name); 
      if (ie4) return document.all[name]; // eval('document.all.' + name); 
      return false; 
    }

  11. Well im not sure... but ive tried my contribution in IE and Firefox and it works just fine.. but it doesnt work on your site for either..

     

    there is a function in that file global.js called

     

    fetch_object .. this is basically the same as getObject function that is in ajax.js.php

     

    see if you can do this..

     

    remove or comment out the getObject function in ajax.js.php

     

    and modify the getStatesRequest function so that instead of getObject(something)...

     

    change it to fetch_object(something)...

     

    there are two lines that need to be changed to that in the function getStatesRequest

     

    let me know how that works out

     

    p.s you may need to change it to fetch_object(something, true)...

     

    J

  12. Hi Jesse,

     

    thats still throwing up a runtime error. Any ideas?

     

    (btw, the page started off as a page from the FEC contribution so I have no idea why the creator changed the form name)

     

    Cheers

     

    Dave

     

    Dave.. I see that you have a link to a file called global.js .. can you post the contents of that file please..

  13. Hi Jesse,

     

    I'm just trying to install this on a very modified page here but I am getting an error when i change country from the default...

     

    the error is

     

    error2.jpg

     

    Any ideas what the cause might be?

     

    Thanks

     

    Dave

     

     

    Ive updated the code so that it works with multiple country drop-downs and any form name..

     

    code changes..

     

    first open catalog/includes/ajax.js.php

     

    remove the original two functions named getStates and getStatesRequest

     

    and replace with these functions

    function getStates(countryID, form, div_element) {
    if (request.readyState == 4 || request.readyState == 0) {
    	// indicator make visible here..
    	getObject("indicator").style.visibility = 'visible';
    	var contentType = "application/x-www-form-urlencoded; charset=UTF-8";
    	var fields = "action=getStates&country="+countryID;
    
    	request.open("POST", 'create_account.php', true);
    	//request.onreadystatechange = getStatesRequest;
    	request.onreadystatechange = function() {
    		getStatesRequest(request, form, div_element);
    	};
    
    	request.setRequestHeader("Content-Type", contentType);		
    	request.send(fields);
    }
    }										
    //Called when the AJAX response is returned.
    function getStatesRequest(request, form, div_element) {
    var next = false;
    if (request.readyState == 4) {
    	// make hidden
    	getObject('indicator').style.visibility = 'hidden';
      getObject(div_element).innerHTML = request.responseText;
    	if (form.state) {
    		form.state.focus();
    	} else if (form.zone_id) {
    	form.zone_id.focus();
    	}
    }
    }

     

    next open catalog/create_account.php

     

    change

    <?php echo tep_get_country_list('country',$country,'class="formtextinput" onChange="getStates(this.value);"') . ' ' . (tep_not_null(ENTRY_COUNTRY_TEXT) ? '<span class="inputRequirement">' . ENTRY_COUNTRY_TEXT . '</span>': ''); ?>

     

    to

    <?php echo tep_get_country_list('country',$country,'class="formtextinput" onChange="getStates(this.value, this.form, \'states\');"') . ' ' . (tep_not_null(ENTRY_COUNTRY_TEXT) ? '<span class="inputRequirement">' . ENTRY_COUNTRY_TEXT . '</span>': ''); ?>

     

    notice the difference in the getStates function call.. two added parameters.. this.form (should never change) and \'states\' this you need to change for any page with multiple country select boxes .. basically if you have a billing select and shipping select change it to be \'billing_states\' and \'shipping_states\' then you also need to change the <DIV element which surrounds the states dropdown in each .. from <div id="states"> to <div id="billing_states"> and for the other one.. shipping states.. should be clear enough?

     

    make the above code changes to the files catalog/includes/modules/checkout_new_address.php and catalog/includes/modules/address_book_details.php

     

    that should be all there is to it..

     

    new package will be uploaded soon..

     

    J

  14. Hi Jesse,

     

    I'm just trying to install this on a very modified page here but I am getting an error when i change country from the default...

     

    the error is

     

    error2.jpg

     

    Any ideas what the cause might be?

     

    Thanks

     

    Dave

     

    The problem i guess is partially my fault i should have realized.. it seems as though you changed the stock osc form name for that page.. the name of the form is usually 'account'

     

    youve changed it to 'checkout' not really sure why that is but in any case

     

    you need to open /catalog/includes/ajax.js.php

     

    and in the getStatesRequest function

     

    find the line that begins with document.account and change it to document.checkout .. for the time being.. let me see if I can change that so its not necessary.. as well you have multiple country selections for shipping address and billing address.. ill see if i can modify it so that it works for multiple country selection boxes..

     

    but for the time being use the above fix... should work..

     

    J

  15. Thanks for taking the time to look at this insaini. Unfortunately - I still have a problem - although slightly improved, because it doesn't show "alabama" every time in edit mode! I applied the entire 1.5.3 version, overwriting everything except languages\english.php which I just left as it was already. In it I have the default state set with define ('DEFAULT_COUNTRY', '223');

    Exact symptoms:

    I'm logged in as an existing customer.

    I am editing an address in my address book - either the default address or any other existing record in my address book. - via address_book_process.php (url is appended with?edit=number)

    Everything looks good, I make my changes and click "update"

    Screen refreshes to same address_book_process.php (url is appended with?edit=number) but with changes in all fields except state.

    Cannot exit the screen via the update button, but no errors are displayed

    Only way out is "back" button or click some other unrelated link

    No changes are saved to any part of the address.

     

    If you would like to see it in action in my not yet active store, http://www.classicbikebooks.com/ Test user: [email protected] password: letmein

     

    Thanks!

     

     

    Ahhh i think i found the problem..

     

    open catalog/address_book_process.php

     

    around line 40

      if (isset($_POST['action']) && ($_POST['action'] == 'process')) {

     

    change to

      if (isset($_POST['action']) && (($_POST['action'] == 'process') || ($_POST['action'] == 'update'))) {

     

     

    Sorry about that.. I will make that change and upload it as a new package hopefully that resolves all issues

     

    OH and also ..

     

    you may want to put the a css tag for the indicator somewhere in your css file

     

    #indicator {
    visibility:hidden;
    }

     

    you can position this as you see fit for your site..

  16. No doubt a really simple thing, but I can't see it and would appreciate your help.

     

    This evening I noticed my installation of the AJAX country/state selector 1.5.1 was not calling up the saved state when Updating an address. Always showing default Alabama - but all the correct zip, address and country and name info. Will not update the state field, and in fact won't let me off the update page because "a required field " is blank. I'm guessing that would be the state field...

     

    To make it even more confusing for me, I have copied the actual files, all of them, from the contribution into place - I had manually changed them a few nights ago, but didn't think I needed to go through that all again. So just copied them all up. New address works fine, jsut update does not. So the source I'm using is exactly what is in the 1.5.1 contribution from April 12.

     

    Is there a bug fix I just haven't noticed posted?

     

    Thanks

    Chris

     

    Ok I have uploaded the fixed version 1.5.3

     

    There are a few small code changes necessary..

     

    First open catalog/includes/functions/ajax.php

     

    change the function declaration line from

    function ajax_get_zones_html($country, $ajax_output = true) {

     

    to

    function ajax_get_zones_html($country, $default_zone = '', $ajax_output = true) {

     

    Next in that same function

    change this part

    		if ( tep_db_num_rows($zones_query) ) {
    		$output .= tep_draw_pull_down_menu('zone_id', $zones_array);	  
    	} else {
    		$output .= tep_draw_input_field('state');
    	}

     

    to this

    		if ( tep_db_num_rows($zones_query) ) {
    		$output .= tep_draw_pull_down_menu('zone_id', $zones_array, $default_zone);	  
    	} else {
    		$output .= tep_draw_input_field('state', $default_zone);
    	}

     

    Now open catalog/create_account.php

     

    change

    						  <?php
    			// +Country-State Selector
    			echo ajax_get_zones_html($country,false);
    			// -Country-State Selector
    			?>

     

    to this

    						  <?php
    			// +Country-State Selector
    			echo ajax_get_zones_html($country,'',false);
    			// -Country-State Selector
    			?>

     

    Do the same above change to file catalog/includes/modules/checkout_new_address.php

     

    Now open catalog/includes/modules/address_book_details.php

     

    and change this

    				// +Country-State Selector
    			echo ajax_get_zones_html($entry['entry_country_id'], false);
    			// -Country-State Selector

     

    to this

    				// +Country-State Selector
    			echo ajax_get_zones_html($entry['entry_country_id'],($entry['entry_zone_id'] == 0 ? $entry['entry_state'] : $entry['entry_zone_id']), false);
    			// -Country-State Selector

     

     

    That should take care of it all

  17. No doubt a really simple thing, but I can't see it and would appreciate your help.

     

    This evening I noticed my installation of the AJAX country/state selector 1.5.1 was not calling up the saved state when Updating an address. Always showing default Alabama - but all the correct zip, address and country and name info. Will not update the state field, and in fact won't let me off the update page because "a required field " is blank. I'm guessing that would be the state field...

     

    To make it even more confusing for me, I have copied the actual files, all of them, from the contribution into place - I had manually changed them a few nights ago, but didn't think I needed to go through that all again. So just copied them all up. New address works fine, jsut update does not. So the source I'm using is exactly what is in the 1.5.1 contribution from April 12.

     

    Is there a bug fix I just haven't noticed posted?

     

    Thanks

    Chris

     

    Hmm.. so this is only when updating an address in the 'my account' area and not when creating an account?

     

    Let me check

  18. Please accept my apologies Insaini. I just get fed up with contributions having loads of rubbish appended to them most of which are useless. I went off "half cocked" because I was having a frustrating evening.

     

    I was wrong to direct this at you, especially as I had not viewed your addition.

     

    Instead of interacting on the web last night perhaps I should have been reading a page or two from "how to make friends and influence people".

     

    <slaps self around head>

     

    Done and Accepted.. I do know what you mean about a lot of junk be added to contribution pages.. makes it tough to know what to download..

  19. Hello friends!

     

    I am back again.

     

    My SPPC works fine. I have been trying to figure out how to add a drop down menu on create_account.php page whereby a new customer can select whether he/she want to register as Retailer or Wholesaler.

     

    Depending on his/her selection, the system will automatically add the account to the specified Customers Group (Retailer or Wholesaler). No more need of sending an email to admin requesting to be added to a certain Customers Group.

     

    I think this way of doing things will be straight, more practical and it’s a good timesaving tip.

     

    Some Customers would rather prefer creating their account and buying right away than creating an account knowing that they have to wait for at least 24h or more for the admin to add them into the appropriate Group.

     

    I scanned the forum and I couldn’t find any topic related to this question.

     

    Is there such a mod? Or how can it do it on create_account.php page?

     

    Thanks very much in advance.

     

    JBS7

     

    Allowing a customer to choose their group is not more practical.. it is time saving however it is problematic.. wholesale purchasers generally are exempt from certain taxes.. i suppose it also depends on where you are.. it also allows regular customers to register as a certain group and see pricing of that particular group..

     

    it is better that a company that wishes to purchase wholesale contact you directly and then you can set them up under a wholesale account.. they will get pricing and even if they have to wait a day its a better way of handling things.. although IMO.. you can setup your store as you like.. you will however have to create a drop down with the available groups you want allowed to be chosen.. and then when the customer is being added you have to add that information to the insert code..

  20. Hi,

    I have the same problem.

    The order it's o.k., it will be register as order, but automatically the user is logged out and the cart become empty.

     

    It's a stressful problem, maybe a code guru will help us?

     

    What does your root .htaccess file look like?

     

    copy and paste here..

     

    also what are your session settings in your admin configuration?

  21. Ah ok steve I probably installed 1.4X for my client and was misremembering.

     

    I've also noticed people starting to add rubbish to the contribution, such a shame, all the best ones like this get killed by the posting of irrelevant crap.

     

    Insaini is a name I've seen doing this before.

     

    WOW.. you seem like an individual that attacks before knowing anything to begin with.. the contribution i uploaded is EXACTLY the same as the previous versions.. with the difference being ONLY AJAX support .. if you had even looked at the code.. I used stevel's function to the T and only abstracted it to a function (thus instead of having 15 lines of code which are exactly the same in 4 different files.. it is contained now in only 1 file.. ) .. you really should open a couple files.. read and see what the difference is before you open your mouth star..

×
×
  • Create New...