Results 1 to 10 of 21

Threaded View

  1. #4
    Join Date
    Jan 2004
    Posts
    66,446
    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.

 

 

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

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