Page 3 of 6 FirstFirst 12345 ... LastLast
Results 21 to 30 of 57
  1. #21
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: Adding special function when order is placed

    Are you in the order class or in your observer when trying to use that product data?
    There's a lot of other information that would help at least someone else... I mean, you may need to recreate the $order or use/deal with the stored order_id to pull the data again.
    But basically posting your current code and/or a thorough explanation of what you're wanting to do makes it easier to provide additional guidance.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  2. #22
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Adding special function when order is placed

    In my earlier post I updated the processProducts() function to loop through $order->products. That is an array of all the products in the current order. The comments I posted in the code in an even earlier post contain links to github where the Order class prepares the array, so you can understand what elements are available inside each product when iterating through the $order->products array.

    As mc12345678 said, it would be easier if you would write out in english all of what you want the code to do.
    .

    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.

  3. #23
    Join Date
    Oct 2020
    Location
    Florida
    Posts
    35
    Plugin Contributions
    0

    Default Re: Adding special function when order is placed

    We have a restaurant that sells food and we need to handle his food order that comes in, we need to put a time frame on those items so those items can only be ordered at certain times. Then we need to email the owner of those items that end up in the cart. Do you know anyone who could help us even if they charge for it?

  4. #24
    Join Date
    Oct 2020
    Location
    Florida
    Posts
    35
    Plugin Contributions
    0

    Default Re: Adding special function when order is placed

    I have gotten everything else I need to work work. But I can't get the attributes to pull I have tried the following.

    PHP Code:

    $product
    ->attributes['option']
    $product->attribute['option']

    $order->products->attributes['option']
    $order->products->attribute['option']

    $product['attributes']['option']

    $product['option']

    $order->product['option']
    $order->products['option']

    $product->products['option']
    $product->product['option'

  5. #25
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Adding special function when order is placed

    Code:
    foreach ($order->products as $product) {
    
    // Option:       $product['attributes']['option']
    // Option Value: $product['attributes']['value']
    // Option ID:    $product['attributes']['option_id']
    // Value ID:     $product['attributes']['value_id']
    // Price:        $product['attributes']['price']
    // Is Free:      $product['attributes']['product_attribute_is_free']
    
    }
    If you need to look up more information about the attribute, you may have to query the db using the option/value id and the product id.
    .

    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.

  6. #26
    Join Date
    Oct 2020
    Location
    Florida
    Posts
    35
    Plugin Contributions
    0

    Default Re: Adding special function when order is placed

    I have tried these but they do not pull the attributes.

  7. #27
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Adding special function when order is placed

    I'm having trouble visualizing what actually "is" happening. Care to enlighten?
    .

    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. #28
    Join Date
    Oct 2020
    Location
    Florida
    Posts
    35
    Plugin Contributions
    0

    Default Re: Adding special function when order is placed

    I am trying to email the attributes when a product is bought.

    PHP Code:
                // Attributes
                
    $product['attributes']['option'] . 
                
    "\n" 
                
    $product['attributes']['value'] . 
    But this does not show the attributes in the email, and yes I have double-checked I have added an attribute to the product.

  9. #29
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: Adding special function when order is placed

    Quote Originally Posted by Famine_1 View Post
    I am trying to email the attributes when a product is bought.

    PHP Code:
                // Attributes
                
    $product['attributes']['option'] . 
                
    "\n" 
                
    $product['attributes']['value'] . 
    But this does not show the attributes in the email, and yes I have double-checked I have added an attribute to the product.
    There's actually another loop that is missing unfortunately:
    Code:
    foreach ($order->products as $product) {
    
    // Option:       $product['attributes'][$attr_index]['option']
    // Option Value: $product['attributes'][$attr_index]['value']
    // Option ID:    $product['attributes'][$attr_index]['option_id']
    // Value ID:     $product['attributes'][$attr_index]['value_id']
    // Price:        $product['attributes'][$attr_index]['price']
    // Is Free:      $product['attributes'][$attr_index]['product_attribute_is_free']
    
    }
    So:
    Code:
    foreach ($order->products as $product) {
        if (!empty($product['attributes'])) {
            foreach ($product['attributes'] as $attribute) {
                // Option:       $attribute['option']
                // Option Value: $attribute['value']
                // Option ID:    $attribute['option_id']
                // Value ID:     $attribute['value_id']
                // Price:        $attribute['price']
                // Is Free:      $attribute['product_attribute_is_free']
            }
        }
    }
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  10. #30
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: Adding special function when order is placed

    I would like to note that determining what the data layout is can be accomplished a number of ways. I prefer to send the results of print_r($arrayVariable, true) to whatever is to be used for reviewing the results... I often will write a debug log to contain the data (assuming that I don't expect a significant number of logs or entries to be made.

    So I might do something like:

    Code:
    foreach ($order->products as $product) {
    
    trigger_error('product data: ' . print_r($product, true), E_USER_WARNING);
    
        if (!empty($product['attributes'])) {
            foreach ($product['attributes'] as $attribute) {
                // Option:       $attribute['option']
                // Option Value: $attribute['value']
                // Option ID:    $attribute['option_id']
                // Value ID:     $attribute['value_id']
                // Price:        $attribute['price']
                // Is Free:      $attribute['product_attribute_is_free']
            }
        }
    }
    That is if I didn't find more within the associated class. In this case it would be related to the code at and around: https://github.com/zencart/zencart/b...order.php#L216

    In this line the array data is captured/assigned by: $this->products[$index]['attributes'][$subindex] = array(

    This indicates that there is another array key between ['attributes'] and the desired key(s).
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 
Page 3 of 6 FirstFirst 12345 ... LastLast

Similar Threads

  1. send me an email when order is placed
    By Funkhouserjm in forum General Questions
    Replies: 1
    Last Post: 29 Jun 2010, 11:54 PM
  2. sideboxes round when placed on right but not when placed on left!
    By hungrytazman in forum Basic Configuration
    Replies: 4
    Last Post: 11 Mar 2010, 09:11 PM
  3. Change 'To:" email when order is placed.
    By joefox in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 9 Apr 2009, 09:00 PM
  4. Order History Not appearing When an Order Is Placed
    By VNLLC in forum General Questions
    Replies: 9
    Last Post: 20 Mar 2009, 09:38 PM
  5. Auto print when order is placed??
    By jbourque in forum General Questions
    Replies: 4
    Last Post: 18 Jul 2008, 06:53 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