Save Multiple Ship-to Addresses Completed
Hi all, I've got this mod done and thought I'd share it - allows you to save multiple ship-to addresses on the profile page.
It creates a nice drop-down menu to choose your profile from, and allows you to switch, add, and delete profiles. Once you've got it going - realize that you have to save your profile the regular x-cart way, and once it's saved you can then hit "create saved profile" to save a copy of it later. Then, modify your profile, click the regular submit to save it, and then click on the "create saved profile" - this will keep adding to the profiles available to "switch to". First, you need to create a php file called createAlt.php and put it in your root directory: Code:
Second, you will need to create a new table in the mysql database - you can use this dump file I created: Code:
Also, alter the customers table like so (thanks techhead): Code:
Third, you will need to modify and create some .tpl files: Create a new .tpl file and put it in the skin1/main folder and call it register_switch_profile.tpl - here is the code: Code:
Now create another new .tpl file called register_delete_altprofile.tpl and put it in this same spot. Code:
Now modify skin1/customer/main/register.tpl - adding this into your chosen location depending on where you want it to showup in the form: Code:
{* Borealis Media - "profile switch" -grep- the other half of this is in register_contact_info.tpl*} Then, in this same file, somewhere in the "hidden inputs" or below the regular submit button, add another like this that will show the user the new create saved profile button: Code:
<input type="hidden" name="createAltFunc"> Ok, now last step - modify one of the "register" .tpl's in the skin1/main folder to add this - I've put mine in the register_contact_info.tpl but it doesn't matter which you put it in. Code:
{* Borealis Media - the other half of this is in register.tpl*} Cheers, hope you all find some use of this mod, took me awhile ;o) BTW - I've got it working on both the 3.5.x branch and the 4.0.x branch. Instinctual Colorado X-Cart Versions 3.5.x - 4.0.x |
this looks like just what I'm after... but I'm having a little bit of trouble getting it up and going on 4.0.12.
first I think you missed the following database change: Code:
ALTER TABLE `xcart_customers` ADD `profile` INT( 11 ) DEFAULT '0' NOT NULL ; secondly... I now get a sql error when I try and add a new profile along the lines of Code:
INVALID SQL: 1064 : You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'A'";}' where sessid='15558c80e44a16a535a6f2cdd9cda4d8'' at line ... blah blah... too much to paste in here any ideas |
Any chance of an link to an example?
It sounds interesting but I am not entirely sure what exactly it does :D |
Unfortunately where I have this working is password-protected shopping only. However, I've taken a screenshot of the profile page so that you can all see what it does:
http://www.borealismedia.com/multi-ship.jpg :o) Cheers - - - techhead I'm checking out your errors right now... Instinctual Colorado X-Cart Versions 3.5.x - 4.0.x |
Techhead - - I'm running this on version 4.0.9 -= the error you're getting seems to be with altering the session - around this line in my code:
// now update the session Have you checked that .12 still stores sessions in this same table and fields? Can you paste the rest of the error so I can take a look at it? Thanks - Instinctual Colorado X-Cart Versions 3.5.x - 4.0.x |
Can't see the screen shot :(
|
Never mind... yes I can just took a while to download :)
Looks good, think this will go on my 'todo' pile! |
really? Weird, shows up here for me...
Prolly just taking awhile to load... Cheers! Instinctual Colorado X-Cart Versions 3.5.x - 4.0.x |
That's a sweet little mod that one, kudos instinctual!
|
I've got a client looking over our dev shopping cart at the moment so I wont be able to get the error to you awhile. You're right though, it has to do with the data being (or trying to be) stored in the database.
What you've done looks like you can only select one shipping destination for the cart What I'm after would be to hack this to allow customers to select different shipping destinations for each product. So if a customer buys 5 copys of the Java Book, the customer can send 2 copies to Peter, 1 copy to Paul, and the other 2 copies to Mary. Tax isn't going to be an issue as it will all be in the same tax zone, however shipping destinations/charges will come into it. |
Wow, yeah, that would be a nice add-on as well. What I've done will just allow you to switch ship-to profiles easily without having to "overwrite" your profile each time you purchase.
It was made for a company that has people ordering and shipping to the same locations all the time, so they just store their shipipng locations in there and I made it so when you login it just redirects you to the modify profile page for you to choose your profile right away. I've also worked this mod in a way where the entire profile is switchable - not just the ship-to information. That way you can have several people share the same membership level and not worry about overwriting each other's profiles. Lemme know when you get that done, would love to take a look ;o) Instinctual Colorado X-Cart Versions 3.5.x - 4.0.12 |
Did you all have any luck tracking down the sql problem? I'm also getting invalid sql: 1064 in 4.0.5
Thanks for any help, Bill |
I am in the process of trying to implement this right now, and just needing a little verification on this step:
Quote:
1. Somewhere in teh hidden inputs - could you be more specific, as I am not a coder. I can find the lines that say hidden input, but not sure if i just throw it in there that it wont mess something else up. Could you give a line number suggestion? 2. Then it says add another one like this... does that mean I actually need to copy paste this in this document twice? |
mhmm
Hi there, all I'm referring to is that you need to add this code:
Code:
<input type="hidden" name="createAltFunc"> Into the area that already contains the hidden inputs that are built-in to the existing x-cart template - you need to have it in that general area but where EXACTLY you put it is upto you. If you take a look at the screenshot, the code above is what's creating the "creat saved profile" button - which is not standard x-cart design - so where you put it is upto you, just make sure you include the code above somewhere in that template where you'd like the button to show up in the html code. |
Followed the instructions to the letter, and I'm getting this error:
Code:
Warning: Cannot modify header information - headers already sent by (output started at /homepages/35/d117449933/htdocs/createAlt.php:3) in /homepages/35/d117449933/htdocs/createAlt.php on line 10 Anyone know what how to fix? Complete newbie to both x-cart and PHP, so please reply as if I'm 2. :) TIA |
Hi,
Please read this thread and will solve your problem... http://forum.x-cart.com/viewtopic.php?t=20678 |
Make sure that you only have the php code in the createAlt.php. Remove any other code like:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> It is also better to use long php tags just in case your server doesn't support short tags... use: Code:
<?php // code goes here ?> Code:
<? // code goes here ?> For more information on the error your getting check out www.php.net |
techhead, Thanks for your reply.
I just figured out that what I had was a "whitespace error". I had a couple returns before and after the code, causing the errors. Now that that's solved, I'm getting a javascript error in this: Code:
{* Borealis Media - the other half of this is in register.tpl*} the error is: Code:
Object doesn't support this property or method the error is referring to the line: Code:
obj.action = 'createAlt.php'; I have chmoded createAlt.php to 777 w/ no change. The javascript is in {literal} {/literal} tags in the .tpl Any ideas? |
Mulitple ship to addresses
Hi,
I just tried to implement the multiple ship to address drop down and it is working. I was hoping someone could give me suggestion of how to get it to work. I also get this error INVALID SQL: 1064 : You have an error in your SQL syntax near 's Goldberg Variations";s:12:"product_type";s:0:"";s:5:"price" ;d:13.99;s:5:"taxes' at line 1 SQL QUERY FAILURE: update xcart_sessions_data set data = 'a:44:{ ..... too much to print. Was a fix made to this? Actually, I only started getting this error after I made a bunch of changes to the shipping options (added UPS online and other misc changes) Before i made all of the shipping option changes, I did not get the session error but it still did not work. I did not get anything to appear in the alt shipping address drop down in my profie. Anyone made any headway on this?? THanks, Robin |
CORRECTION to last email
:( I meant to say....
I just tried to implement the multiple ship to address drop down and it is NOT working. Sorry for the quick typo |
I love the idea of this mod. In looking over the code, I am confused as to where $alt_profiles gets populated. Maybe I am missing something obvious but it seems like no profiles would get displayed. Any insight would be appriciated
Thanks |
alt_profiles doesn't get written to - that's not a table - it's mentioned in the code in spots as that's what we were calling it when we developed it. We have variable names called that, but otherwise data gets written to xcart_shipping_addresses table.
All of that logic is in createalt.php... |
Thanks for the reply. I guess I didnt explain my question well enough. In the register_switch_profile.tpl you list out all the profiles in the select box via a loop over all the profiles for that user.
{section name=switchProfile loop=$alt_profiles} I don't see where you are assigning this data from the PHP to the template. createAlt.php handles the creation, deletion, and switching. But I dont see it handling the population of the data to be displayed in the drop downs. Thanks! |
ah, that's handled in the javascript that I have in register_contact_info.tpl - one of my last snippets of code there.
|
I have installed this mod but it doesn't seem to be working right.
When I click on register as a new user the "Create Saved Profile" button is on the page, but doesn't do anything. It will work when I click on the "Modify profile" link because it is passing through mode=update, but it doesn't appear to be saving a profile to the drop down list. I checked the database and see a new entry in xcart_shipping_addresses for every time I pressed the "Create Saved Profile" button, but still nothing showing in the dropdown list: http://www.strangdirect.com/xcart/register.php |
first - if installed right, this should not be showing up until you've actually already registered and created a profile with user/pass. It needs to be surrounded with some if/then tags that it looks like you missed.
Once you've then logged in after registering for the first time, you will then see a dropdown list that will populate with alternate profiles as they are created. Keep in mind you have to create the first profile and use the regular x-cart submit button, and then can click the "create saved profile" button to copy that profile so that you can enter a new one, save, copy, enter new one, save, copy, etc. |
The drop down list is not showing up untill after the registration is complete, the button is showing up but does not do anything even after the registration, unless you first click on modify profile.
|
Great Mod, I installed it but have a little hitch
I am able to modify profile and then submit, but when I come back to add the profile it does not add up to the drop down list and I still have no alternative profiles, i guess I am not able to add the profile , how do I check for that |
Re: Mulitple ship to addresses
Quote:
This occurs because the sessions are completely regenerated, which means re-establishing your cart contents. If one of your cart contents has an apostrophe or quote in it, then it will cause the SQL to break. To fix this find: Code:
$new[$key] = $value; Replace with: Code:
$new[$key] = addslashes($value); |
I do not get any errors but it is not saving the addresses.
Any ideas? |
I think I have a fix for this..I will post as soon as I test it out.
|
Missing alternate profiles
I think there is something missing from the quoted Javascript for register_contact_info.tpl
I cannot see how/where alt_profiles is populated to allow the drop-down boxes to populate. I have applied this mod, can create the alternate shipping profiles, but they never appear in the drop-down lists. This is with XCart Gold 4.0.16 Thanks for any assistance. Regards, Stu |
Doesn't work for me either. I didn't get any errors but this is what happens. I register an account and then go to the modify page. I change the address, and then click on submit. Then I wait for it to reload, and I click on create saved profile. Clicking on that takes me to register.php?mode=update?action=cart. The address is not saved into the dropdown.
I tried this on 4.1.2. |
Has anyone gotten this to work? I am getting the following error:
Quote:
This is in 4.1.0. It is like the information is not posting to createAlt.php. I can not figure out what is wrong. THanks. |
Question
Hi - has anyone gotten this to work on 4.1 as of yet? And if so what did you do to get this to work?
This is a great mod and would be very useful on my site! |
Re: Save Multiple Ship-to Addresses Completed
Is there a working version of this for 4.1.7? We really need this one in one of our carts.
thanks. |
Re: Save Multiple Ship-to Addresses Completed
Bump. Anyone figured this out?
|
Re: Save Multiple Ship-to Addresses Completed
This is what I did on 4.1.9 to make it work (sorry if it wraps). I'm new at xcart so I am winging this.
First, the queries to populate the selectboxes are nowhere in this thread. This is what I have near the end of register.php: Code:
$alt_profile_names = func_query_column("select s_address from xcart_shipping_addresses where login = '$userinfo[login]'"); I had to make several changes to createAlt.php: Code:
<?php That may have gotten mangled. I don't remember anything else signficant. I did move the "Create New Profile" button from after the main submit button, to up where it makes more sense in the form. Seems to work fine there, though I have not really tested any of this much. Thanks for the original post. Saved me beaucoup time. |
Re: Save Multiple Ship-to Addresses Completed
This looks like a great mod and would like to implement. I was wondering if there is full clean code/instructions for this mod somewhere for 4.1.9?
Is there somewhere where you can download mods in a contained .zip folder and a version tracker? I've seen this for other open source products but haven't come across it here. Thanks! |
Re: Save Multiple Ship-to Addresses Completed
yeah I'd like to use this too.
|
All times are GMT -8. The time now is 04:48 PM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.