PHP Classes

File: example_zencart.php

Recommend this page to a friend!
  Classes of Felix Manea   Zencart Bridge   example_zencart.php   Download  
File: example_zencart.php
Role: Example script
Content type: text/plain
Description: example on how to use this class
Class: Zencart Bridge
Manage users of Zencart installation
Author: By
Last change: - added the session handler inclusion into example script
Date: 16 years ago
Size: 4,831 bytes
 

Contents

Class file image Download
<?php
/*
Zencart manipulation Class
By Felix Manea (felix.manea@gmail.com)
www.ever.ro
Licensed under LGPL
NOTE: You are required to leave this header intact.
*/
//add session handler and class
require_once("zencart_session_handler.php");
require_once(
"zencart.class.php");

$zencart_action = @$_REQUEST["op"];
$zencart = new zencart(dirname(dirname(dirname(__FILE__)))."/zencart/");

switch(
$zencart_action){
    case
"login":
       
//DATE TEST
       
$vars = array("customers_email_address" => "test@test.com", "customers_password" => "test");
       
//END DATE TEST
       
$zencart_result = $zencart->user_login($vars);
    break;
    case
"logout":
       
$zencart_result = $zencart->user_logout();
    break;
    case
"loggedin":
       
$zencart_result = $zencart->user_loggedin();
    break;
    case
"user_add":
       
//DATE TEST
       
$vars = array(
           
//user
           
"customers_gender" => "m",
           
"customers_firstname" => "Felix",
           
"customers_lastname" => "Manea",
           
"customers_dob" => "1980-04-25",
           
"customers_email_address" => "test@test.com",
           
"customers_nick" => "murtzunel",
           
"customers_telephone" => "123",
           
"customers_fax" => "234",
           
"customers_password" => "test",
           
"customers_newsletter" => "0",
           
//address
           
"address_book_id" => 20,
           
"entry_gender" => "m",
           
"entry_company" => "my company",
           
"entry_firstname" => "Felix",
           
"entry_lastname" => "Manea",
           
"entry_street_address" => "my street",
           
"entry_suburb" => "my suburb",
           
"entry_postcode" => "8700",
           
"entry_city" => "my city",
           
"entry_state" => "my state",
           
//"entry_country_id" => "",
            //"entry_zone_id" => "",
           
"countries_iso_code_2" => "fr",
        );
       
//END DATE TEST
       
$zencart_result = $zencart->user_add($vars);
    break;
    case
"user_delete":
       
//DATE TEST
       
$vars = array(/*"user_id" => "53", */"customers_email_address" => "test@test.com");
       
//END DATE TEST
       
$zencart_result = $zencart->user_delete($vars);
    break;
    case
"user_update":
       
//DATE TEST
        //DATE TEST
       
$user = array(
           
//user
           
"customers_gender" => "m",
           
"customers_firstname" => "Felix edit",
           
"customers_lastname" => "Manea edit",
           
"customers_dob" => "1980-04-25",
           
"customers_email_address" => "test@test1.com",
           
"customers_nick" => "murtzunel",
           
"customers_telephone" => "123",
           
"customers_fax" => "234",
           
"customers_password" => "test",
           
"customers_newsletter" => "0",
        );
       
$customer_id = $zencart->user_email2id($user["customers_email_address"]);
       
$addresses = array(
            array(
           
//address
           
"address_book_id" => 20,
           
"customers_id" => $customer_id,
           
"entry_gender" => "m",
           
"entry_company" => "my company 1",
           
"entry_firstname" => "Felix 1",
           
"entry_lastname" => "Manea 1",
           
"entry_street_address" => "my street 1",
           
"entry_suburb" => "my suburb 1",
           
"entry_postcode" => "8700",
           
"entry_city" => "my city",
           
"entry_state" => "my state 1",
           
//"entry_country_id" => "",
            //"entry_zone_id" => "",
           
"countries_iso_code_2" => "fr",
            ),
            array(
           
//address
           
"address_book_id" => 21,
           
"customers_id" => $customer_id,
           
"entry_gender" => "m",
           
"entry_company" => "my company 2",
           
"entry_firstname" => "Felix 2",
           
"entry_lastname" => "Manea 2",
           
"entry_street_address" => "my street",
           
"entry_suburb" => "my suburb",
           
"entry_postcode" => "8700",
           
"entry_city" => "my city",
           
"entry_state" => "my state",
           
//"entry_country_id" => "",
            //"entry_zone_id" => "",
           
"countries_iso_code_2" => "ro",
            ),
            array(
           
//address
           
"address_book_id" => 22,
           
"customers_id" => $customer_id,
           
"entry_gender" => "m",
           
"entry_company" => "my company 3",
           
"entry_firstname" => "Felix 3",
           
"entry_lastname" => "Manea 3",
           
"entry_street_address" => "my street 3",
           
"entry_suburb" => "my suburb",
           
"entry_postcode" => "8700",
           
"entry_city" => "my city",
           
"entry_state" => "my state",
           
//"entry_country_id" => "",
            //"entry_zone_id" => "",
           
"countries_iso_code_2" => "bg",
            ),
        );
       
//END DATE TEST
       
$zencart_result = $zencart->user_update($user);
        foreach(
$addresses as &$address) $zencart->address_update($address);
    break;
    case
"change_password":
       
//DATE TEST
       
$vars = array(
           
//user
           
"customers_email_address" => "test@test123.com",
           
"customers_password" => "test123",
        );
       
//END DATE TEST
       
$zencart_result = $zencart->user_change_password($vars);
    break;
}


if(isset(
$zencart_result)) echo $zencart_result."<br /><br />";
?>
<a href="?op=loggedin">loggedin</a><br />
<a href="?op=login">login</a><br />
<a href="?op=logout">logout</a><br />
<a href="?op=user_add">user_add</a><br />
<a href="?op=user_delete">user_delete</a><br />
<a href="?op=user_update">user_update</a><br />
<a href="?op=change_password">change_password</a><br />