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

    help question sending attribute value to payment processor

    Hi guys,

    there is probably a basic php solution for this but it's a little over my head atm (though I am trying to learn).

    In my payment module there is a section where I can specify a reference number for the order. This is the default setting:

    payment_reference => zen_create_random_value(16, 'digits');

    We don't need a 16 digit random number. Something more specific will be more useful to us. I have tried the following and they both work:

    function before_process() {
    global $_POST, $response, $db, $order, $orders;

    $order->info['cc_number'] = $_POST['cc_number'];
    $order->info['cc_owner'] = $_POST['cc_owner'];


    payment_reference => = $_POST['cc_owner'];
    //(to put the credit card owner'
    s name in the reference section)

    payment_reference => = $_POST['cc_number'],
    //(to put the credit card number in the reference section *just for a test, I wouldn't save this info*)



    On the product page we have a required attribute that is automatically generated (an 8 digit internal reference number).

    The text field with this number as the following id's:
    The products_attributes_id is 304.
    The options_id is 28.

    The question is: How do we get the text value inputted for this attribute to show up here?

    I would like to do something like this:

    $order->info['attribute_28'] = $_POST['attribute_28'];

    payment_reference => = $_POST['attribute_28'];


    obviously it doesn't work as it is now. what do i need to do to allow it?

    even pointing me towards another forum post in the right direction would be a great help.

    thanks in advance,


    Regards,
    Shaztesting

    P.S The module is directone: http://www.zen-cart.com/archived_con.../directone.zip

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

    help question text field (attribute) values to PHP variable

    I would like to make an attribute text field into a php variable.

    Ideally the value the customer places in that field should be able to be retrived later on in the checkout process.

    How do i best do this?


    The attribute on my product page has an input name and the form is submited via POST then shouldn't I be able to call it back later on with $_POST["input name"]?

    For example this simple form works in a test environment.
    Code:
    <form action="index.php" method="post">
    <input type="text" name="attribute" />
    <input type="Submit" name="Submit">
    </form>
    index.php
    Code:
    <?php $attrib = $_POST["attribute"]; ?>
    Your Attribute value is <?php echo $attrib; ?>
    However when I input this into the store it no longer works.

    I tested this by modifying the product page to include an additional field
    Code:
    <input type="text" name="attribute" />
    and modifying the next stage in the process, the shopping cart 'tpl_shopping_cart_default.php' with
    Code:
    <?php $attrib = $_POST["attribute"]; ?>
    Your Attribute value is <?php echo $attrib; ?>
    What happens is the shopping cart page only shows 'Your Attribute value is' and not the variable.

    1. Why does this code work in a test environment and not in the store?


    If we can get this to work then there will be one final hurdle. The attribute input name that Zen Cart uses is 'id[text_12]'
    Whenever we need to retrieve the variable we couldn't use
    Code:
    <?php $attrib = $_POST["id[text_12]"]; ?>
    Your Attribute value is <?php echo $attrib; ?>
    since the square brackets aren't escaped. How do we do that? Can we use "\" somehow to escape the next characters?
    Anyway, I'm probably getting ahead of myself. At this stage I have to get text field -> php variable working in zencart.

    As always, I appreciate any help anyone can prove on the matter.

    If i'm going about this the wrong way then feel free to correct me,

    Thanks in advance,
    Shaztesting

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

    help question Re: text field (attribute) values to PHP variable

    Quote Originally Posted by shaztesting View Post

    1. Why does this code work in a test environment and not in the store?
    I figured this part out. Although you are directed to the shopping cart checkout - the target of the POST is not. That's why I can't get that value on the third page (tpl_shopping_cart_default.php).

    Is this possible using a $_SESSION variable? How would I do this without interfering with the store's existing sessions?

    What about global $_POST; ?

    I've looked into ways that others have retrieved attribute information and modified some of the Linkpoint code:

    Code:
    <?php
    function before_process() {
        global $order, $db;
        $myorder = array();
    	
    	if (isset($order->products[$i]['attributes'])) {
    			for ($j=0, $m=sizeof($order->products[$i]['attributes']); $j<$m; $j++) {
    			  $myorder["items"][$i]['options' . $j]['name'] = $order->products[$i]['attributes'][$j]['option'];
    			  $myorder["items"][$i]['options' . $j]['value'] = $order->products[$i]['attributes'][$j]['value'];
    			}
    		  }
    	$attrib = $order->products[$i]['attributes'][$j]['value'];
    	
    }
    ?>
    Your Attribute value is <?php echo $attrib;
    ?>

    But obviously it doesn't work in this state. Could someone please let me know how i can use this to retrieve specific attribute values, perhaps using $i and $j?

    Regards,
    Shaztesting

  4. #4
    Join Date
    Jan 2004
    Posts
    66,391
    Blog Entries
    7
    Plugin Contributions
    81

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

    Quote Originally Posted by shaztesting View Post
    I would like to make an attribute text field into a php variable.

    Ideally the value the customer places in that field should be able to be retrived later on in the checkout process.
    Perhaps you can explain a lot more detail about what end result you're looking for, without even thinking about code?
    including but not limited to:
    Why are you doing this?
    What data do you want where and for what purpose?
    .

    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. #5
    Join Date
    Jun 2009
    Posts
    69
    Plugin Contributions
    0

    help question Re: text field (attribute) values to PHP variable

    Quote Originally Posted by DrByte View Post
    Why are you doing this?
    I need to have a certain attribute value sent to my payment processor. This is an internal tracking number which we generate from our ERP system and we need this to be sent with successful payments so we can track orders by simply logging into the payment gateway's administration backend.

    More details can be found here: http://www.zen-cart.com/forum/showthread.php?t=130824


    Quote Originally Posted by DrByte View Post
    What data do you want where and for what purpose?
    It is an integer, up to 8 digits that is automatically prefilled for the customer. In the directone payment module we need to retrieve this number and include it in the array that is sent to the payment gateway.

    If you need any more information please let me know,

    Regards,
    Shaztesting

  6. #6
    Join Date
    Jan 2004
    Posts
    66,391
    Blog Entries
    7
    Plugin Contributions
    81

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

    So, the customer is keying this number in?
    .

    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. #7
    Join Date
    Jan 2004
    Posts
    66,391
    Blog Entries
    7
    Plugin Contributions
    81

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

    Quote Originally Posted by shaztesting View Post
    I've merged the 2 threads since they're the same topic.
    .

    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. #8
    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
    So, the customer is keying this number in?
    Not exactly, we are prefilling that in automatically but they pressing the 'add to cart' button.

    So in their shopping cart they see their product as well as a few attributes, one of which we have generated for them.

  9. #9
    Join Date
    Jan 2004
    Posts
    66,391
    Blog Entries
    7
    Plugin Contributions
    81

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

    Quote Originally Posted by shaztesting View Post
    I've looked into ways that others have retrieved attribute information and modified some of the Linkpoint code:

    Code:
    <?php
    function before_process() {
        global $order, $db;
        $myorder = array();
    
    	if (isset($order->products[$i]['attributes'])) {
    			for ($j=0, $m=sizeof($order->products[$i]['attributes']); $j<$m; $j++) {
    			  $myorder["items"][$i]['options' . $j]['name'] = $order->products[$i]['attributes'][$j]['option'];
    			  $myorder["items"][$i]['options' . $j]['value'] = $order->products[$i]['attributes'][$j]['value'];
    			}
    		  }
    	$attrib = $order->products[$i]['attributes'][$j]['value'];
    	
    }
    ?>
    Your Attribute value is <?php echo $attrib;
    ?>
    I would suggest that that's the right snippet of code to work from, perhaps like this:
    Code:
    <?php
    
    function before_process()
    {
      global $order;
      $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'] == 77) {
              $erpNumber = $order->products[$i]['attributes'][$j]['value'];
              break;
            }
          }
        }
      }
    }
    ?>
    Your Attribute value is <?php echo $erpNumber;  ?>
    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.
    Last edited by DrByte; 10 Aug 2009 at 04:10 AM. Reason: changed to "break" instead of "continue" and pre-initialized $erpNumber
    .

    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.

  10. #10
    Join Date
    Jan 2004
    Posts
    66,391
    Blog Entries
    7
    Plugin Contributions
    81

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

    Quote Originally Posted by shaztesting View Post
    Not exactly, we are prefilling that in automatically but they pressing the 'add to cart' button.

    So in their shopping cart they see their product as well as a few attributes, one of which we have generated for them.
    Is your ERP system feeding *other* data as well? Or just this one number?
    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.
    .

    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 1 of 3 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