Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Looking for a bit of PHP code - create_account to send customer info straight to


sofaking

Recommended Posts

Hi All,

 

It has been a while since I have had to tinker with the code for my site but I am now looking for a bit of code writing help.

 

The idea I have is this:

I am using a company called sign-up.to to run my newsletters from but I have been manually adding new customers details to it as they get an account at my store.

 

I have since found that even better than uploading my customer database as a csv file i can automate this with API.

 

I think I have the API setup on their side but I need to alter my own code to send the customers details over to them.

 

My assumssion is that I could alter my create_account.php file to add the new customer to my oscommerce database AND send similar details over to sign-up.to

 

The instructions I have from them are I have to

 

 

Managing subscriptions

The URL for the script you will need to call is: https://api.sign-up.to/capture.php

 

For the script to work correctly you will need to pass four GET parameters in the URL. The four parameters

are as follows:

cid - Account identifier

hash - Encrypted access hash

mode - Defines which application feature you would like to use

pid - (required for adding new subscribers) - This is the ID of the list you would like to manage. This can be viewed with the main web

application by hovering the mouse pointer over the icon for the relevant list.

Further parameters will be required in order to access the defined feature set using ‘mode’.

 

I have the cid, hash and pid values.........the mode I assume is 'add' from the next bit of info

 

 

Adding a subscriber

In order to add a subscriber to your Sign-Up.to account you will need to set ‘mode’ to add (mode=add) and

pass one of the following key identifiers:

 

email - email address

mobile - mobile number

 

Without one of the key identifiers above, the application will not process your request

 

The below optional information can also be passed to the application as GET parameters:

title, first_name, surname, day_birth, month_birth, year_birth, house_number, street_name,

town, county, postcode, phone and company_name, confirm

 

The optional information below, have predefined values:

email_format - ‘html’ or ‘text’

gender - ‘male’ or ‘female’

dob_slash - This is an alternative to the separate entries above. If found this

option will override the above options *_birth. (Format:

DD/MM/YYYY)

marital_status - ‘single’, ‘married’, ‘separated’, ‘divorced’ or ‘co-habiting’

employment_status - ‘employed’, ’self-employed’, ‘unemployed’, ’student’ or ‘retired’

country - country is stored as ISO alpha-2 country code (a full list can be

found here: http://en.wikipedia.org/wiki/ISO_3166-1)

confirm - ‘1’ or ‘0’ - when set in conjunction with the email key

identifier, triggers a double opt-in email

confirmation_redirect - Any URL the subscriber should be redirected to once the double optin

link is set. This option is only valid when combined with an email

address and confirm=1. The system will validate any URL and won’t

attempt to redirect the user should the URL not return an OK

response at the time of initial subscription.

 

Note: Only one subscription can be added each time this script is invoked. Once invoked, this script will

return ‘1’ for success. In the event of an error whilst the application processes your request, an error

message and support details will be returned.

 

Example call

https://api.sign-up.to/capture.php?cid=10&hash=aaa&mode=add&pid=12&email=me%40example.com

 

I only need the name and email address set from the oscommerce create_account.php but I don't know how to write in the code to that file that will do/build the above line of code.

(including setting the oscommerce $firstname and $email_address to sign-up.to's first_name and email

and where to add it to the file)

I'm not looking to redirect the customer over to them - just to automatically send their details over to them

 

 

 

Any help would be great!

 

Cheers,

 

Michael

Link to comment
Share on other sites

Hi

 

If you are using osC 2.3 look at jQuery serialise http://api.jquery.com/serialize/ if you construct a bit of code in the create_account.php file just before the line tep_redirect(tep_href_link(FILENAME_CREATE_ACCOUNT_SUCCESS, '', 'SSL')); so that you have all the variables available.

 

If < 2.3 import jQuery and then try it.

 

Just make sure you wrap it all in a try....catch loop so that if it the extra code errors then your customer still gets registered (you'll also need to start the whole lot off with a check to ensure that $newsletter has been set

Link to comment
Share on other sites

Thanks for the direction......

 

i get how the

<script>
   function showValues() {
  var str = $("form").serialize();
  $("#results").text(str);
   }
   $(":checkbox, :radio").click(showValues);
   $("select").change(showValues);
   showValues();
</script>

 

to be sent to the URL for the script you will need to call is: https://api.sign-up.to/capture.php

 

Thanks again for the help

Link to comment
Share on other sites

If someone drops an account, does that automatically drop their newsletter? Or do they get one until they explicitly say "stop spamming me!"? I'm thinking that a PHP utility (or even a direct MySQL command) run once a day (cron job) to export your customer database to a CSV might be better. Customers who have dropped their account presumably don't want to receive mailings, so that would keep the active customer list in sync with the mailings. You would also have to honor explicit requests to drop the newsletter, which might be handled by the newsletter people (overriding the customer list you provide). Something that could track the last time a customer visited, and send a tickler to invite them to drop by, would be useful, as would something to remind someone making a purchase that they had dropped their newsletter subscription and might be missing out on deals. Just some thoughts...

Link to comment
Share on other sites

Thanks for the direction......

 

i get how the

<script>
function showValues() {
 var str = $("form").serialize();
 $("#results").text(str);
}
$(":checkbox, :radio").click(showValues);
$("select").change(showValues);
showValues();
</script>

 

to be sent to the URL for the script you will need to call is: https://api.sign-up.to/capture.php

 

Thanks again for the help

 

Sorry I meant to say - how do I get the quote above to call the URL above

 

Cheers,

 

Michael

Link to comment
Share on other sites

  • 2 weeks later...

Hi again,

 

I did a bit of reading and thought that this would do the trick, but I think I'm missing something

// end of email to store owner
$url1 = 'https://api.sign-up.to/capture.php?cid=123&hash=aaa&mode=add&pid=12345&email=';
$urlemail = $email_address;
$urltotal = $url1."".$urlemail;
$ch = curl_init($urltotal);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
  tep_redirect(tep_href_link(FILENAME_CREATE_ACCOUNT_SUCCESS, '', 'SSL'));
   }
 }

 

But this doesn't send the new users info over to sign-up.to

 

Any helpful ideas?

 

Thanks

Link to comment
Share on other sites

Hi

 

Double check the url you're Curling to?

 

Try

 

// end of email to store owner
$url1 = 'https://api.sign-up.to/capture.php?cid=123&hash=aaa&mode=add&pid=12345&email='.$email_address;
//$urlemail = $email_address;
//$urltotal = $url1."".$urlemail;
$ch = curl_init($url1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
	 // tep_redirect(tep_href_link(FILENAME_CREATE_ACCOUNT_SUCCESS, '', 'SSL'));

exit($url1);
    }
 }

 

That should pass over the same info and then leave you with the url echoed out onto the screen rather than sending you to checkout_success.

 

If the URL looks correctly formed then copy that to the clipboard then go look at the signup - if the email is not there then try pasting the url directly into the address bar of the browser to see if the url is OK

 

If that works then it's your curl that's being naughty - if it does not then double check the url formation

Link to comment
Share on other sites

Hi

 

Double check the url you're Curling to?

 

Try

 

// end of email to store owner
$url1 = 'https://api.sign-up.to/capture.php?cid=123&hash=aaa&mode=add&pid=12345&email='.$email_address;
//$urlemail = $email_address;
//$urltotal = $url1."".$urlemail;
$ch = curl_init($url1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
	 // tep_redirect(tep_href_link(FILENAME_CREATE_ACCOUNT_SUCCESS, '', 'SSL'));

exit($url1);
 }
}

 

That should pass over the same info and then leave you with the url echoed out onto the screen rather than sending you to checkout_success.

 

If the URL looks correctly formed then copy that to the clipboard then go look at the signup - if the email is not there then try pasting the url directly into the address bar of the browser to see if the url is OK

 

If that works then it's your curl that's being naughty - if it does not then double check the url formation

 

Thanks Bob,

 

This echoed the url in my browser - it didn't send the details over to send-to mind you.

I copied the echoed url into the address bar and that sent the details over.

 

So my next bit of work is to get it to send the url directly behind the scenes.

 

Again thanks for the help Bob - i'm one step closer!!

Link to comment
Share on other sites

Hi

 

Arrr - sounds like it's not Curling then?

 

Try this and see if $results shows anything ....

 

// end of email to store owner
$url = 'https://api.sign-up.to/capture.php?cid=123&hash=aaa&mode=add&pid=12345&email='.$email_address;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION , 1);		  
curl_setopt($ch, CURLOPT_HEADER ,0);				
curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1);		 
$results = curl_exec($ch);
exit($results);

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...