Zen Cart Logo
Forums / Addon Payment Modules / oscommerce to zen-cart module adaptation

oscommerce to zen-cart module adaptation

Locked

Views: 4,488

Results 1 to 11 of 11
This thread is locked. New replies are disabled.
4 Dec 2009, 12:07 PM
#1
dzetasystem avatar

dzetasystem

New Zenner

Join Date:
Sep 2009
Location:
Rzeszów / Poland
Posts:
10
Plugin Contributions:
0

oscommerce to zen-cart module adaptation

hello. i have a oscommerce payment module cal "zagiel" and i want to make it work in zen-cart.

how to modifi to work with zen-cart ?

module : eraty.pl/inne/pliki_oscommerce_eraty.zip

its polish module, php is wel know for all of you :):)

how to make change to work it ?

i need a advice :(

Please help.

4 Dec 2009, 12:11 PM
#2
tino_schlegel avatar

tino_schlegel

Totally Zenned

Join Date:
Nov 2007
Location:
Melbourne, Australia
Posts:
532
Plugin Contributions:
0

Re: oscommerce to zen-cart module adaptation

Read the Developer wiki. You will find the information you need.

4 Dec 2009, 12:50 PM
#3
dzetasystem avatar

dzetasystem

New Zenner

Join Date:
Sep 2009
Location:
Rzeszów / Poland
Posts:
10
Plugin Contributions:
0

Re: oscommerce to zen-cart module adaptation

thanks.

but i hawe problem

Fatal error: Call to a member function Execute() on a non-object in ....

function check() {
      if (!isset($this->_check)) {
        $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_RATY_ZAGIEL_STATUS'");
        $this->_check = tep_db_num_rows($check_query);
      }
      return $this->_check;

the sessions pach is in the sessions.php ( for bug of php 5.2.x )

and id don't now what to do with it ..
oryginal code

 function check() {
      if (!isset($this->_check)) {
        $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_RATY_ZAGIEL_STATUS'");
        $this->_check = tep_db_num_rows($check_query);
      }
      return $this->_check;
4 Dec 2009, 3:23 PM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: oscommerce to zen-cart module adaptation

This is a copy of the function check from the Check/Money Order moneyorder payment module ...

See if this helps you with the $db and tep_db_num_rows errors:

    function check() {
      global $db;
      if (!isset($this->_check)) {
        $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_MONEYORDER_STATUS'");
        $this->_check = $check_query->RecordCount();
      }
      return $this->_check;
    }
5 Dec 2009, 2:49 PM
#5
dzetasystem avatar

dzetasystem

New Zenner

Join Date:
Sep 2009
Location:
Rzeszów / Poland
Posts:
10
Plugin Contributions:
0

Re: oscommerce to zen-cart module adaptation

YES ! it works :D :)

but is another problem ...
http://dzetasystem.pl/screen1.jpg

no text and no values i look in this function install what happends but it loks normal like other payment modules..

  function install() {
	 global $db;
      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Włączony', 'MODULE_PAYMENT_RATY_ZAGIEL_STATUS', 'True', 'Włącza (true) lub nie (false) moduł płatno¶ć Raty Żagiel eRaty', '6', '1', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())");
      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Payment Zone', 'MODULE_PAYMENT_RATY_ZAGIEL_ZONE', '0', 'Jeżeli wybrano strefę ten rodzaj płatno¶ci będzie aktywny tylko dla niej.', '6', '2', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', now())");
      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Kolejno¶ć wy¶wietlania.', 'MODULE_PAYMENT_RATY_ZAGIEL_SORT_ORDER', '0', 'Kolejno¶ć wy¶wietlania. Najniższe wy¶wietlane są na początku.', '6', '0', now())");
      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) values ('Domy¶lny status zamówienia', 'MODULE_PAYMENT_RATY_ZAGIEL_ORDER_STATUS_ID', '0', 'Ustaw status zamówień realizowanych tą formą płatno¶ci', '6', '0', 'zen_cfg_pull_down_order_statuses(', 'zen_get_order_status_name', now())");
   }

    function remove() 
	   {
		global $db;
      $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
    }

and i canot remove this module or uninstal from database.

i dont know what is wrong ..

im sorry for bader you guys bud im not a php specialist. ..

5 Dec 2009, 4:16 PM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: oscommerce to zen-cart module adaptation

If you are going to give Sort Order to 1 module, be sure to give them to all modules and they need to be unique ...

You can try to do a REMOVE, INSTALL, REMOVE, INSTALL and then see if you can edit ...

Otherwise, you have additional errors somewhere in the code ...

5 Dec 2009, 4:25 PM
#7
dzetasystem avatar

dzetasystem

New Zenner

Join Date:
Sep 2009
Location:
Rzeszów / Poland
Posts:
10
Plugin Contributions:
0

Re: oscommerce to zen-cart module adaptation

this is a all module code

i canot uninstal instal and give a sort order to this module ..

i dont know what is wrong .. :(

<?php
/*
Wykonanie integracji RATY ZAGIEL eRaty
Arkadiusz Krakiewicz
[email protected]

KODOWANIE ZNAKÓW: ISO (latin2)
*/


  class raty_zagiel {
    var $code, $title, $description, $enabled;

// class constructor
    function raty_zagiel() {
      global $order;

      $this->code = 'raty_zagiel';
      $this->title = MODULE_PAYMENT_RATY_ZAGIEL_TEXT_TITLE;
      $this->description = MODULE_PAYMENT_RATY_ZAGIEL_TEXT_DESCRIPTION;
      $this->sort_order = MODULE_PAYMENT_RATY_ZAGIEL_SORT_ORDER;
      $this->enabled = ( (MODULE_PAYMENT_RATY_ZAGIEL_STATUS == 'True') ? true : false);

      if ((int)MODULE_PAYMENT_RATY_ZAGIEL_ORDER_STATUS_ID > 0) {
        $this->order_status = MODULE_PAYMENT_RATY_ZAGIEL_ORDER_STATUS_ID;
      }

      if (is_object($order)) $this->update_status();
    }

// class methods
    function update_status() {
      global $order;

      if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_RATY_ZAGIEL_ZONE > 0) ) {
        $check_flag = false;
        $check_query = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_RATY_ZAGIEL_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
        while ($check = $db->Execute($check_query)) {
          if ($check['zone_id'] < 1) {
            $check_flag = true;
            break;
          } elseif ($check['zone_id'] == $order->delivery['zone_id']) {
            $check_flag = true;
            break;
          }
        }

        if ($check_flag == false) {
          $this->enabled = false;
        }
      }

// disable the module if the order only contains virtual products
      if ($this->enabled == true) {
        if ($order->content_type == 'virtual') {
          $this->enabled = false;
        }
      }
	  
	  if ($this->enabled == true) {
        if ($order->info['total'] - $order->info['shipping_cost'] < 100) { // Wyłączenie metody płatno¶ci raty Zagiel jezeli zamowienie jest < 100zł bez ceny przesyłki
          $this->enabled = false;
        }
      }
	  
    }

    function javascript_validation() {
      return false;
    }

    function selection() {
      return array('id' => $this->code,
                   'module' => $this->title,
				   'opis' => $this->description);
    }

    function pre_confirmation_check() {
      return false;
    }

    function confirmation() {
      return false;
    }
	
// START WYSWIETLANIE INFORMACJI PRZED ZLOZENIEM ZAMOWIENIA (checkout_confirmation.php)
function process_button() {
global $order, $cart;

$koszt = $cart->show_total()+$order->info['shipping_cost'];

$tekst = '
  <script language="javascript">
  <!--
  function PoliczRate(koszyk)	{
        	 window.open(\'https://www.eraty.pl/symulator/oblicz.php?numerSklepu=' . ZAGIEL_NUMER_SKLEPU . '&wariantSklepu=' . ZAGIEL_WARIANT_SKLEPU . '&typProduktu=0&wartoscTowarow=\'+koszyk, \'Policz_rate\', \'width=630,height=500,directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no\');
  }
  function nowe_okno() {
        	 window.open(\'http://www.zagiel.com.pl/kalkulator/jak_kupic.html\', \'nowe_okno\', \'width=600,height=500,directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no\');
  }
  //-->
  </script>
<tr>
    <td>' . tep_draw_separator('pixel_trans.gif', '100%', '10') . '</td>
</tr>
<tr>
    <td class="main"><b>Zapoznaj się z procedurą Raty Żagiel (przez internet)</b></td>
</tr>
      
      <tr>
        <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
          <tr class="infoBoxContents">
            <td><table border="0" width="100%" cellspacing="2" cellpadding="2">
              <tr>
			  <td align="left" class="main">
<a OnClick="PoliczRate(' . $koszt . ');" style="cursor: pointer;">' . tep_image_button('zagiel_oblicz_rate.gif', ZAGIEL_OBLICZ_RATE) . '</a>
  </td>    <td align="center" class="infoboxcontents" style="padding-left: 50px;">
	Zapoznałem się <a OnClick="nowe_okno();" style="cursor: pointer;" title="Zapoznaj się z procedurą udzielenia kredytu ratalnego..."><b>z procedurą udzielenia kredytu ratalnego Raty Żagiel</b></a> ' . tep_draw_checkbox_field('raty_zgoda', '', true, '') . '
	</td>
    </tr>
	<tr>
	<td class="main" align="center" colspan="2">
	<b>Po kliknięciu "Potwierdź Zamówienie" zostaniesz przeniesiony na stronę systemu ratalnego Żagiel, <br>po czym wypełnisz krótki wniosek o udzielenie kredytu ratalnego.</b>
	</td>
              </tr>
            </table></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td>' . tep_draw_separator('pixel_trans.gif', '100%', '10') . '</td>
      </tr>
<tr>
<td align="right">
';

return $tekst;
}
// KONIEC WYSWIETLANIE INFORMACJI PRZED ZLOZENIEM ZAMOWIENIA (checkout_confirmation.php)


    function before_process() {
      return false;
    }
	
	
// START TWORZENIE FORMULARZA WYSYLANEGO DO SYSTEMU eRATY ZAGIEL S.A. (checkout_proccess.php)
function after_process() {
global $order, $currencies, $cart, $insert_id;

function clean_nazwa($data) {
	$data = preg_replace ('/"/', '', $data);
	$data = preg_replace ('/"/', '', $data);
	return $data;
	}
	
function clean_prod($data) {
    $data = preg_replace ('/[^0-9,.]/', '', $data);
	$data = preg_replace ('/ /', '', $data);
	$data = preg_replace ('/,/', '.', $data);
    return $data;
    }

$tekst = '<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
  <html' . HTML_PARAMS . '>
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=' . CHARSET . '"> 
  <title>Złóż wniosek o kredyt ratalny - Kontynuuj...</title>
  <style type="text/css">
  body {
  background: #fff;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 22px;
  color: #fff;
  font-weight: bold;
  }
  </style>
  </head>
  <body>
  <div style="color: #333; width: 100%; text-align: center; position: absolute; top: 150px;">
  Właśnie dokonałeś zakupu. 
  <br>Zapraszamy do złożenia wniosku ratalnego 
  <br><span style="color: #26aeca;">e</span><span style="color: #003399;">Raty</span> Żagiel S.A.
  <br><br>
<form name="formularz_eRaty" action="https://www.eraty.pl/symulator/krok1.php" method="post">
';

$products = $cart->get_products();              

for ($i=0, $nr=1; $i<sizeof($products); $i++, $nr++) {
	
	$tekst .= '
	<input name="idTowaru' . $nr . '" readonly="readonly" type="hidden" value="' . $products[$i]['id'] . '">
	<input name="nazwaTowaru' . $nr . '" readonly="readonly" type="hidden" value="' . clean_nazwa($products[$i]['name']) .'">
	<input name="wartoscTowaru' . $nr . '" readonly="readonly" type="hidden" value="' . number_format(clean_prod($currencies->display_price($products[$i]['final_price'], tep_get_tax_rate($products[$i]['tax_class_id']), '1')), 2, '.', '') . '">
	<input name="liczbaSztukTowaru' . $nr . '" readonly="readonly" type="hidden" value="' . $products[$i]['quantity'] . '">
	<input name="jednostkaTowaru' . $nr . '" readonly="readonly" type="hidden" value="szt.">
	';
	
}

$wartoscTowarow = 0;

if ($order->info['shipping_cost'] != '' && $order->info['shipping_cost'] != 0) {
		
	$tekst .= '
		<input name="idTowaru' . $nr . '" readonly="readonly" type="hidden" value="KosztPrzesylki">
		<input name="nazwaTowaru' . $nr . '" readonly="readonly" type="hidden" value="Koszt Przesyłki">
		<input name="wartoscTowaru' . $nr . '" readonly="readonly" type="hidden" value="' . $order->info['shipping_cost'] . '">
		<input name="liczbaSztukTowaru' . $nr . '" readonly="readonly" type="hidden" value="1">
		<input name="jednostkaTowaru' . $nr . '" readonly="readonly" type="hidden" value="szt.">
	';

	$wartoscTowarow = $order->info['shipping_cost'];

} else {

	$nr -= 1;

}

$wartoscTowarow += $cart->show_total();

$tekst .= '
		<input type="hidden" name="wartoscTowarow" value="' . $wartoscTowarow . '">
		<input type="hidden" name="liczbaSztukTowarow" value="' . $nr . '">
		<input type="hidden" name="numerSklepu" value="' . ZAGIEL_NUMER_SKLEPU . '">
		<input type="hidden" name="typProduktu" value="0">
		<input type="hidden" name="wariantSklepu" value="' . ZAGIEL_WARIANT_SKLEPU . '">
		<input type="hidden" name="sposobDostarczeniaTowaru" value="' . preg_replace('#\s\(.*\)#', '', clean_nazwa($order->info['shipping_method'])) . '">
		<input type="hidden" name="nrZamowieniaSklep" value="' . $insert_id . '">
		<input type="hidden" name="pesel" value="">
		<input type="hidden" name="imie" value="' . clean_nazwa($order->billing['firstname']) . '">
		<input type="hidden" name="nazwisko" value="' . clean_nazwa($order->billing['lastname']) . '">
		<input type="hidden" name="email" value="' . clean_nazwa($order->customer['email_address']) . '">
		<input type="hidden" name="telKontakt" value="' . clean_nazwa($order->customer['telephone']) . '">
		<input type="hidden" name="ulica" value="' . clean_nazwa($order->billing['street_address']) . '">
		<input type="hidden" name="nrDomu" value="">
		<input type="hidden" name="nrMieszkania" value="">
		<input type="hidden" name="miasto" value="' . clean_nazwa($order->billing['city']) . '">
		<input type="hidden" name="kodPocz" value="' . clean_nazwa($order->billing['postcode']) . '">
		<input type="hidden" name="char" value="' . CHARSET . '">
		<input type="hidden" name="wniosekZapisany" value="' . HTTP_SERVER . DIR_WS_HTTP_CATALOG . 'raty_zagiel.php?akcja=tak&id_zamowienie=">
		<input type="hidden" name="wniosekAnulowany" value="' . HTTP_SERVER . DIR_WS_HTTP_CATALOG . 'raty_zagiel.php?akcja=nie&id_zamowienie=">
   		<input type="image" src="' . DIR_WS_LANGUAGES . 'polish/images/buttons/zagiel_zloz_wniosek.gif" border="0" alt="Kontynuuj - Złóż wniosek o kredyt ratalny eRaty Żagiel S.A." title="Złóż wniosek o kredyt ratalny eRaty Żagiel S.A.">
		</form>
		</div>
		</body>
		</html>
';

echo $tekst;

}
// KONIEC TWORZENIE FORMULARZA WYSYLANEGO DO SYSTEMU eRATY ZAGIEL S.A. (checkout_proccess.php) 

    function get_error() {
      return false;
    }

	 function check() {
      global $db;
      if (!isset($this->_check)) {
        $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_MONEYORDER_STATUS'");
        $this->_check = $check_query->RecordCount();
      }
      return $this->_check;
    }
	 
//    function check() {
//      if (!isset($this->_check)) {
 //       $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_RATY_ZAGIEL_STATUS'");
  //      $this->_check = RecordCount($check_query);
 //     }
 //     return $this->_check;
 //   }

    function install() {
	 global $db;
      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Włączony', 'MODULE_PAYMENT_RATY_ZAGIEL_STATUS', 'True', 'Włącza (true) lub nie (false) moduł płatno¶ć Raty Żagiel eRaty', '6', '1', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())");
      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Payment Zone', 'MODULE_PAYMENT_RATY_ZAGIEL_ZONE', '0', 'Jeżeli wybrano strefę ten rodzaj płatno¶ci będzie aktywny tylko dla niej.', '6', '2', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', now())");
      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Kolejno¶ć wy¶wietlania.', 'MODULE_PAYMENT_RATY_ZAGIEL_SORT_ORDER', '0', 'Kolejno¶ć wy¶wietlania. Najniższe wy¶wietlane są na początku.', '6', '0', now())");
      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) values ('Domy¶lny status zamówienia', 'MODULE_PAYMENT_RATY_ZAGIEL_ORDER_STATUS_ID', '0', 'Ustaw status zamówień realizowanych tą formą płatno¶ci', '6', '0', 'zen_cfg_pull_down_order_statuses(', 'zen_get_order_status_name', now())");
   }

    function remove() 
	   {
		global $db;
      $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
    }

    function keys() {
      return array('MODULE_PAYMENT_RATY_ZAGIEL_STATUS', 'MODULE_PAYMENT_RATY_ZAGIEL_ZONE', 'MODULE_PAYMENT_RATY_ZAGIEL_ORDER_STATUS_ID', 'MODULE_PAYMENT_RATY_ZAGIEL_SORT_ORDER');
    }
  }
?>
5 Dec 2009, 4:35 PM
#8
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: oscommerce to zen-cart module adaptation

The main problem is you used the example I gave you but did not change the code to match your module:

     function check() {
      global $db;
      if (!isset($this->_check)) {
        $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_MONEYORDER_STATUS'");
        $this->_check = $check_query->RecordCount();
      }
      return $this->_check;
    }

Needs to read:

     function check() {
      global $db;
      if (!isset($this->_check)) {
        $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_RATY_ZAGIEL_STATUS'");
        $this->_check = $check_query->RecordCount();
      }
      return $this->_check;
    }

Next, you have to fix all of the code with:
tep_

to use the proper Zen Cart functions ... you still have several in your code ...

5 Dec 2009, 4:37 PM
#9
dzetasystem avatar

dzetasystem

New Zenner

Join Date:
Sep 2009
Location:
Rzeszów / Poland
Posts:
10
Plugin Contributions:
0

Re: oscommerce to zen-cart module adaptation

teplace tep_ to zen_ ?

ok its working i ned to make some new edits in this module but i fink it will be working .

5 Dec 2009, 4:44 PM
#10
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: oscommerce to zen-cart module adaptation

Use the Tools ... Developers Tool Kit ... in your Zen Cart Admin to check that the functions exist ...

In the bottom input box enter one without the tep_ on it, for example, for:
tep_draw_separator

do a search on:
draw_separator

select Catalog and click Search ...

to make sure that there is a matching function ... then use the name of the function that you find ...

16 Dec 2009, 5:02 PM
#11
dzetasystem avatar

dzetasystem

New Zenner

Join Date:
Sep 2009
Location:
Rzeszów / Poland
Posts:
10
Plugin Contributions:
0

Re: oscommerce to zen-cart module adaptation

hi again..

i have next probloems .. module have 5 php

checkout_confirmation.php
checkout_process.php
product_info.php
shopping_cart.php

there is lot of code and i dont know where put that code ..

ehhh...