Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 21
  1. #11
    Join Date
    Jun 2009
    Posts
    69
    Plugin Contributions
    0

    Default Re: text field (attribute) values to PHP variable

    Quote Originally Posted by DrByte View Post
    That check is based on options_id 28 and values_id 77. It's going to be much more complicated to go based on products_attributes_id.
    Adjust the 77 according to your data.
    Thanks DrByte, but I don't think I implemented it properly.

    The markup for the form has the text field as follows:
    <input type="text" name="id[txt_5]" size="32" maxlength="32" value="" id="attrib-5-0" />

    Does '5-0' mean an options id of 5 and a value of 0? I looked at the products_attributes table and the 'options_id' field has '5' and 'options_values_id' has '0' (there was no value_id field).

    I inputted those numbers into the snipped which i placed in the tpl_checkout_shipping_default.php page to test the echo and it didn't work.

    So where did I go wrong?

  2. #12
    Join Date
    Jun 2009
    Posts
    69
    Plugin Contributions
    0

    Default Re: text field (attribute) values to PHP variable

    Quote Originally Posted by DrByte View Post
    Is your ERP system feeding *other* data as well? Or just this one number?
    There are a number of text fields (attributes), all prefilled.
    Quote Originally Posted by DrByte View Post
    Can you tell me how/why that number is generated? ... because it might be a lot easier just to have the payment module query the ERP system for that same value, and skip the whole use of attributes ... unless you're using the attribute for a specific reason.
    The ERP system is written in .NET and is integrated with an ASP.NET webpage on IIS webserver. Passing this lead id over URL seemed like the most logical choice, rather than trying to integrate php/mysql into the whole thing.

    Just for a test I copied the <!-- Loop through all products /--> code from the tpl_shopping_cart_default.php page just to see if I could display a list of all the atributes, just like on the shopping cart page. That didn't work either. Are these related?

  3. #13
    Join Date
    Jun 2009
    Posts
    69
    Plugin Contributions
    0

    Default Re: text field (attribute) values to PHP variable

    Quote Originally Posted by shaztesting View Post
    Just for a test I copied the <!-- Loop through all products /--> code from the tpl_shopping_cart_default.php page just to see if I could display a list of all the atributes, just like on the shopping cart page. That didn't work either. Are these related?

    Ok, i just realised that these pages don't have the same header.php files. After i copied the contents of the shopping cart's header.php I can display the list of attributes on any page.

    Still no success in echoing just one of them so I'm guessing I just went off in a tangent...

  4. #14
    Join Date
    Jan 2004
    Posts
    66,380
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: text field (attribute) values to PHP variable

    Quote Originally Posted by shaztesting View Post
    Thanks DrByte, but I don't think I implemented it properly.

    I inputted those numbers into the snipped which i placed in the tpl_checkout_shipping_default.php page to test the echo and it didn't work.

    So where did I go wrong?
    The snippet of code I gave you should go in the payment module, not in a template file. It should be merged into any existing code in the before_process() function already in the file.
    .

    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.

  5. #15
    Join Date
    Jun 2009
    Posts
    69
    Plugin Contributions
    0

    Default Re: sending attribute value to payment processor

    I did try that with no success so I then tried echoing it back on other pages to see if the right attribute we getting called in at all.

    here is how i inserted it into the payment module:

    Code:
    function before_process() {
    	  global $_POST, $response, $db, $order, $orders;
    
    
      $erpNumber = '';
      if (isset($order->products[$i]['attributes']))
      {
        for ($j = 0, $m = sizeof($order->products[$i]['attributes']); $j < $m; $j ++)
        {
          if ($order->products[$i]['attributes'][$j]['option_id'] == 28) {
            if ($order->products[$i]['attributes'][$j]['value_id'] == 0) {
              $erpNumber = $order->products[$i]['attributes'][$j]['value'];
              break;
            }
          }
        }
      }
    
    
    	  if (MODULE_PAYMENT_DIRECTONE_STORE_CC_NUMBER == 'True') {
          $order->info['cc_number'] = $_POST['cc_number'];
          }
          $order->info['cc_expires'] = $_POST['cc_expires'];
          $order->info['cc_type'] = $_POST['cc_type'];
          $order->info['cc_owner'] = $_POST['cc_owner'];
          $order->info['cc_cvv'] = $_POST['cc_cvv'];
          
    
    	  // DATA PREPARATION SECTION
          unset($submit_data);  // Cleans out any previous data stored in the variable
    
          // create a random order id
          $uid = $erpNumber; // Create a UID for the order to be sent as payment_reference 
    
    	  // Populate an array that contains all of the data to be sent to DirectOne
    	  $submit_data = array(
    	  vendor_name => MODULE_PAYMENT_DIRECTONE_VENDOR_NAME, // Vendor Login ID
    	  vendor_password => MODULE_PAYMENT_DIRECTONE_VENDOR_PASSWORD, // Vendor Password
    	  card_number => $_POST['cc_number'],
    	  card_type => 'AUTO',
    	  card_expiry => $_POST['cc_expires'],
    	  card_holder => $_POST['cc_owner'],
    	  card_cvv => $_POST['cc_cvv'],
    	  payment_amount => number_format($order->info['total'], 2, '.', '') * 100,
    	  payment_reference => $uid);  // Unique Transaction ID

    Anything wrong?

    Was I using the right tables to collect the option_id and values_id numbers?

  6. #16
    Join Date
    Jan 2004
    Posts
    66,380
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: sending attribute value to payment processor

    Quote Originally Posted by shaztesting View Post
    I did try that with no success so I then tried echoing it back on other pages to see if the right attribute we getting called in at all.
    The code I gave you only works if the $order variable is set, and *that* only happens while in the midst of processing an order. That's why that code is useless in a template file for example, and is why I've largely ignored anything you've said about putting code in template files.
    Quote Originally Posted by shaztesting View Post
    if ($order->products[$i]['attributes'][$j]['option_id'] == 28) {
    if ($order->products[$i]['attributes'][$j]['value_id'] == 0) {
    So, what was your reasoning behind choosing '0' ?
    Quote Originally Posted by shaztesting View Post
    Was I using the right tables to collect the option_id and values_id numbers?
    I don't understand the question.
    .

    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.

  7. #17
    Join Date
    Jan 2004
    Posts
    66,380
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: sending attribute value to payment processor

    Open phpMyAdmin and run the following query:
    Code:
    select products_attributes_id, products_id, options_id, options_values_id  from products_attributes where products_attributes_id = 308;
    What is the output?
    .

    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.

  8. #18
    Join Date
    Jun 2009
    Posts
    69
    Plugin Contributions
    0

    Default Re: sending attribute value to payment processor

    Quote Originally Posted by DrByte View Post
    Open phpMyAdmin and run the following query:
    Code:
    select products_attributes_id, products_id, options_id, options_values_id  from products_attributes where products_attributes_id = 308;
    What is the output?
    That doesn't work becuase i don't have a 308 yet. But the attributes id of 304 is the one that I am after.

    When I run the query for 304 i get the following output:

    product_attributes_id=304
    products_id=13
    options_id=28
    option_values_id=0

  9. #19
    Join Date
    Jun 2009
    Posts
    69
    Plugin Contributions
    0

    Default Re: sending attribute value to payment processor

    Quote Originally Posted by DrByte View Post
    So, what was your reasoning behind choosing '0' ?
    I got that value from the products_attributes table where the 'options_id' field has '28' and 'options_values_id' has '0'

    Quote Originally Posted by DrByte View Post
    I don't understand the question.
    I was just making sure that the products_attributes table was the right one to be querying

  10. #20
    Join Date
    Jan 2004
    Posts
    66,380
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: sending attribute value to payment processor

    It seems I left out an important section

    Try this:
    Code:
    function before_process() {
    	  global $response, $db, $order, $orders;
    
    
      $erpNumber = '';
    
      reset($order->products);
      for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
        if (isset($order->products[$i]['attributes']))
        {
          for ($j = 0, $m = sizeof($order->products[$i]['attributes']); $j < $m; $j ++)
          {
            if ($order->products[$i]['attributes'][$j]['option_id'] == 28) {
              if ($order->products[$i]['attributes'][$j]['value_id'] == 0) {
                $erpNumber = $order->products[$i]['attributes'][$j]['value'];
                break;
              }
            }
          }
        }
      }
    Don't forget the added brace } near the end.
    .

    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.

 

 
Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. Different payment processor depending on order value.
    By ryanthemadone in forum Built-in Shipping and Payment Modules
    Replies: 2
    Last Post: 10 Feb 2010, 01:40 PM
  2. Adult payment processor
    By imagek in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 13 Aug 2007, 04:58 PM
  3. read only attribute value size too small/ import html in read only attribute value
    By nazzaw in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 22 Jan 2007, 03:49 PM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR