Results 1 to 10 of 64

Hybrid View

  1. #1
    Join Date
    Jan 2004
    Posts
    66,450
    Plugin Contributions
    81

    Default Re: Create a new module for International Checkout payment module

    Quote Originally Posted by icecold View Post
    I will make the change to $_SERVER, as you suggested
    You don't need it, because you're not using it ... at least, not in that function.
    Quote Originally Posted by icecold View Post
    but if the array $products, gets it's content in the shopping cart, why will it pass empty fields to my class?
    First, because payment modules are not activated on the shopping cart page, there's no way the $productsArray will have any data in it anyway.
    Second, every function starts clean, and knows nothing about any other variables outside itself. That's just how PHP has always worked. Each function is its own scope. The only way to get around that is to pass parameters to it or to global certain variables, and using global is an older convention only applicable to procedural code, whereas PHP is headed towards object-oriented code instead.
    Quote Originally Posted by icecold View Post
    Do I need to do another db query so ProductsArray[] has data again?
    Yes, as I said, unless you're ON the shopping cart page when the payment module is instantiated and called, none of the shopping cart data is available to you anyway.
    If you want to mimic similar behavior you'll have to copy and duplicate the code to do that.

    You're not merely writing another payment module here. It's more like you're re-architecting a whole new checkout.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  2. #2
    Join Date
    Jul 2008
    Posts
    360
    Plugin Contributions
    0

    Default Re: Create a new module for International Checkout payment module

    Quote Originally Posted by DrByte View Post
    You don't need it, because you're not using it ... at least, not in that function.
    First, because payment modules are not activated on the shopping cart page, there's no way the $productsArray will have any data in it anyway.
    I thought because we were in the same session some vars might had content ... (that was just in theory).


    Quote Originally Posted by DrByte View Post
    Second, every function starts clean, and knows nothing about any other variables outside itself. That's just how PHP has always worked. Each function is its own scope. The only way to get around that is to pass parameters to it or to global certain variables, and using global is an older convention only applicable to procedural code, whereas PHP is headed towards object-oriented code instead.Yes, as I said, unless you're ON the shopping cart page when the payment module is instantiated and called, none of the shopping cart data is available to you anyway.
    If you want to mimic similar behavior you'll have to copy and duplicate the code to do that.
    ok, so the cart data is stored in tables? So I can query them and retrieve it? ...

    Quote Originally Posted by DrByte View Post

    You're not merely writing another payment module here. It's more like you're re-architecting a whole new checkout.

    Yes, more like it, as this system overrides all the functions and takes only raw data from the cart. So in PHP OOP there is no way to 'store' an array and reuse its contents, not even in a SESSION(I am really not familiar with PHP OOP)?

  3. #3
    Join Date
    Jan 2004
    Posts
    66,450
    Plugin Contributions
    81

    Default Re: Create a new module for International Checkout payment module

    Quote Originally Posted by icecold View Post
    So in PHP OOP there is no way to 'store' an array and reuse its contents, not even in a SESSION(I am really not familiar with PHP OOP)?
    Well, yes there is, but Zen Cart 1.x isn't OOP structured.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  4. #4
    Join Date
    Jul 2008
    Posts
    360
    Plugin Contributions
    0

    Default Re: Create a new module for International Checkout payment module

    Quote Originally Posted by DrByte View Post
    Well, yes there is, but Zen Cart 1.x isn't OOP structured.
    ok how about the cart history? I have seen the cart contents get stored there intact, what if I try to retrieve the data from those tables?

    PHP Code:
    for ($i=0$n=sizeof($products); $i<$n$i++) {
      if ((
    $i/2) == floor($i/2)) {

    $productsImage = (IMAGE_SHOPPING_CART_STATUS == zen_image(DIR_WS_IMAGES $products[$i]['image'], $products[$i]['name'], IMAGE_SHOPPING_CART_WIDTHIMAGE_SHOPPING_CART_HEIGHT) : '');
    $quantityField zen_draw_input_field('cart_quantity[]'$products[$i]['quantity'], 'size="4"');
     
    $productsPrice $currencies->display_price($products[$i]['final_price'], zen_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . ($products[$i]['onetime_charges'] != '<br />' $currencies->display_price($products[$i]['onetime_charges'], zen_get_tax_rate($products[$i]['tax_class_id']), 1) : '');
      
    $productsPriceEach $currencies->display_price($products[$i]['final_price'], zen_get_tax_rate($products[$i]['tax_class_id']), 1) . ($products[$i]['onetime_charges'] != '<br />' $currencies->display_price($products[$i]['onetime_charges'], zen_get_tax_rate($products[$i]['tax_class_id']), 1) : '');

    // Create a smaller Array to hold just the data above

      
    $productArray[$i] = array( 'productsImage'=>$productsImage,
                                                
    'productsName'=>$productsName,
                                                
    'quantityField'=>$quantityField,
                                                 
    'productsPrice'=>$productsPrice,
                                      
    'productsPriceEach'=>$productsPriceEach,
                                
    'rowClass'=>$rowClass,
                          
                                
    'id'=>$products[$i]['id']);
    // end FOR loop 
    I borrowed some of the code from header.php my question is will this work, in my class or will it have a conflict problem?

    Just created a new array with the same name and populated it with the same data.

    So later I can use it within my class ...

  5. #5
    Join Date
    Jul 2008
    Posts
    360
    Plugin Contributions
    0

    Default Re: Create a new module for International Checkout payment module

    Quote Originally Posted by icecold View Post
    ok how about the cart history? I have seen the cart contents get stored there intact, what if I try to retrieve the data from those tables?

    PHP Code:
    for ($i=0$n=sizeof($products); $i<$n$i++) {
      if ((
    $i/2) == floor($i/2)) {

    $productsImage = (IMAGE_SHOPPING_CART_STATUS == zen_image(DIR_WS_IMAGES $products[$i]['image'], $products[$i]['name'], IMAGE_SHOPPING_CART_WIDTHIMAGE_SHOPPING_CART_HEIGHT) : '');
    $quantityField zen_draw_input_field('cart_quantity[]'$products[$i]['quantity'], 'size="4"');
     
    $productsPrice $currencies->display_price($products[$i]['final_price'], zen_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . ($products[$i]['onetime_charges'] != '<br />' $currencies->display_price($products[$i]['onetime_charges'], zen_get_tax_rate($products[$i]['tax_class_id']), 1) : '');
      
    $productsPriceEach $currencies->display_price($products[$i]['final_price'], zen_get_tax_rate($products[$i]['tax_class_id']), 1) . ($products[$i]['onetime_charges'] != '<br />' $currencies->display_price($products[$i]['onetime_charges'], zen_get_tax_rate($products[$i]['tax_class_id']), 1) : '');

    // Create a smaller Array to hold just the data above

      
    $productArray[$i] = array( 'productsImage'=>$productsImage,
                                                
    'productsName'=>$productsName,
                                                
    'quantityField'=>$quantityField,
                                                 
    'productsPrice'=>$productsPrice,
                                      
    'productsPriceEach'=>$productsPriceEach,
                                
    'rowClass'=>$rowClass,
                          
                                
    'id'=>$products[$i]['id']);
    // end FOR loop 
    I borrowed some of the code from header.php my question is will this work, in my class or will it have a conflict problem?

    Just created a new array with the same name and populated it with the same data.

    So later I can use it within my class ...
    I think I forgot to add >>>
    $products = $cart->get_products();
    at the top

  6. #6
    Join Date
    Jul 2008
    Posts
    360
    Plugin Contributions
    0

    Default Re: Create a new module for International Checkout payment module

    Anything wrong with these code?
    I am getting a not found error in admin/modules.php local server
    But couldn't find why

    Warning: include(C:/server/xampp/htdocs/store/includes/languages/english/modules/payment/ic.php) [function.include]: failed to open stream: No such file or directory in C:\server\xampp\htdocs\store\admin\modules.php on line 173

    Warning: include() [function.include]: Failed opening 'C:/server/xampp/htdocs/store/includes/languages/english/modules/payment/ic.php' for inclusion (include_path='.;C:\server\xampp\php\pear\') in C:\server\xampp\htdocs\store\admin\modules.php on line 173


    PHP Code:

    // Admin mod section ---

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

        function 
    install() {
            global 
    $db;
    /*      zen_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Allow International Checkout', 'MODULE_PAYMENT_IC_STATUS', 'True', 'Do you want to accept International Checkout payments?', '6', '0', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())");
          zen_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('International Checkout Company', 'MODULE_PAYMENT_IC_COMPANY', '', 'Company used for International Checkout payments', '6', '0', now())");*/
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable International Checkout Module', 'MODULE_PAYMENT_IC_STATUS', 'True', 'Do you want to accept International Checkout payments?', '6', '130', '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, date_added) values ('Sort order of display.', 'MODULE_PAYMENT_IC_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '131' , now())");
        
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('International Checkout Company ID', 'MODULE_PAYMENT_IC_COMPANY', '', 'Company used for International Checkout payments', '6', '132', now())");
       }

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

        function 
    keys() {
          return array(
    'MODULE_PAYMENT_IC_STATUS''MODULE_PAYMENT_IC_SORT_ORDER''MODULE_PAYMENT_IC_COMPANY');
        }
      } 

 

 

Similar Threads

  1. How to create new payment module?
    By Macedonium in forum Built-in Shipping and Payment Modules
    Replies: 2
    Last Post: 15 May 2009, 09:47 PM
  2. Create payment module for cc gateway
    By ccppll in forum Built-in Shipping and Payment Modules
    Replies: 7
    Last Post: 22 Apr 2009, 05:00 PM
  3. How to Create a Transaction ID for Payment Module?
    By Diego Vieira in forum Built-in Shipping and Payment Modules
    Replies: 0
    Last Post: 21 Mar 2009, 04:40 PM
  4. How to create new payment module?
    By mscro in forum Built-in Shipping and Payment Modules
    Replies: 9
    Last Post: 28 Apr 2008, 12:23 AM
  5. How do I create a new payment module?
    By meeven in forum Built-in Shipping and Payment Modules
    Replies: 7
    Last Post: 12 Aug 2007, 01:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg