Results 1 to 10 of 10
  1. #1
    Join Date
    Jan 2010
    Posts
    182
    Plugin Contributions
    0

    Default Super_Invoice - Check customer orders count (background check)

    Hello all,

    I am close but no cigar on checking the customers orders and if greater than 1, then no action.

    Trouble I am having is getting the history of orders. Here is the code I have so far...

    PHP Code:
           $customers_orders $db->Execute("select o.orders_id, o.date_purchased
                                              from " 
    TABLE_ORDERS " o
                                              where customers_id = '" 
    . (int)$order_check->customers_id "'");
           
    $no_history = ($customers_orders->recordCount() = 1); 
    I am getting " Fatal error: Can't use method return value in write context " referring to the last line above. Any guidance would be appreciated!

  2. #2
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Super_Invoice - Check customer orders count (background check)

    recordCount() should be RecordCount() and = should be ==

    But what are you really trying to test? If there is only 1 Order? Or if there is at least 1 Order?
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  3. #3
    Join Date
    Jan 2010
    Posts
    182
    Plugin Contributions
    0

    Default Re: Super_Invoice - Check customer orders count (background check)

    Thanks - silly little things overlooked! I will work on that right now.

    Basically checking to see if it is the customer's 1st (and only) order. That way we know they are a 1st time buyer and flag them if the order is over $x.

  4. #4
    Join Date
    Jan 2010
    Posts
    182
    Plugin Contributions
    0

    Default Re: Super_Invoice - Check customer orders count (background check)

    Works great! Thanks Ajeh
    here is what I did to check customer's orders and if only 1 order and 1st time buyer...

    PHP Code:
           $customers_orders $db->Execute("select o.orders_id, o.date_purchased
                                              from " 
    TABLE_ORDERS " o
                                              where customers_id = '" 
    . (int)$order_check->customers_id "'");
           
    $no_history = ($customers_orders->RecordCount() == 1); 
    Then on the super_invoice I used $no_history to flag the customer. Use any method or special heading of your choice.

  5. #5
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Super_Invoice - Check customer orders count (background check)

    Thanks for the update that this is working for you and the explanation of its use for you ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  6. #6
    Join Date
    Jan 2010
    Posts
    182
    Plugin Contributions
    0

    Default Re: Super_Invoice - Check customer orders count (background check)

    I came up with another feature though that is of use - order age.

    If the customer orders list is newer than 35 days. This is within credit card billing cycle for fraud and chargebacks.

    I tested this on a dev site - seemed to work. Hard to test completely on a dev site based on the others parameter checks I have.

    PHP Code:
           $customers_orders $db->Execute("select o.orders_id, o.date_purchased
                                              from " 
    TABLE_ORDERS " o
                                              where customers_id = '" 
    . (int)$order_check->customers_id "'");
           
           
    $days35fromnow strtotime("+35 days"strtotime("<date-from-db>"));
           
    $no_history = ($customers_orders->date_purchased >= $days35fromnow); 

  7. #7
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Super_Invoice - Check customer orders count (background check)

    At a glance ... you have an error:
    Code:
    $no_history = ($customers_orders->date_purchased >= $days35fromnow);
    This should be:
    Code:
    $no_history = ($customers_orders->fields['date_purchased'] >= $days35fromnow);
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  8. #8
    Join Date
    Jan 2010
    Posts
    182
    Plugin Contributions
    0

    Default Re: Super_Invoice - Check customer orders count (background check)

    It seems to only grab the current order date_purchased rather than the whole potential list of order based on customer_id

    Shouldn't this code select ALL o.orders_id from the given customer?
    PHP Code:
    where customers_id '" . (int)$order_check->customers_id . "'" 
    This should grab the customer_id based on the order, but not the date_purchased from that order.

  9. #9
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Super_Invoice - Check customer orders count (background check)

    You grab all orders but then only are getting data from the first one of whatever is grabbed ...

    I am not sure how you are using the results, but if you are trying to list something per order, you might do the SELECT with the current order_id and customer_id ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  10. #10
    Join Date
    Jan 2010
    Posts
    182
    Plugin Contributions
    0

    Default Re: Super_Invoice - Check customer orders count (background check)

    Well, come to find out the "look at all orders within 35 days" is the best way to go in our case, but isn't working correctly with the code above.
    What is important is if their list of orders spans MORE than 35 days. Having just more than one order doesn't cut it.

    So what I was trying to do is select all orders based on the customer ID with the ID taken from the current orderID from the invoice. Then take date_purchased of all orders produced to see if any order is older than 35 days old from now. #4 below.

    If no, then take action

    Here's the whole thing and what we use it for for anyone's use....
    Check the following and if it meets requirements, display wording at the top of the invoice. We use this one among many other personal features not listed...
    1. Checks match of billing/shipping address line 1
    2. If order is over a $ threshold of choice
    3. Order is not a certain payment module
    4. Customer meets requirements of no_history (orders are greater than 35 days old)

    PHP Code:
     $customers_orders $db->Execute("select o.orders_id, o.date_purchased
                                              from " 
    TABLE_ORDERS " o
                                              where customers_id = '" 
    . (int)$order_check->customers_id "'");
           
    $days35fromnow strtotime("+35 days"strtotime("<date-from-db>"));
           
    $no_history = ($customers_orders->fields['date_purchased'] < $days35fromnow); 
    Further down to display wording on the invoice...

    PHP Code:
    <?php
    $headings_array 
    = array();

    if ((
    $order_check->fields['delivery_street_address'] != $order_check->fields['billing_street_address'] and $order_check->fields['delivery_street_address'] != '' && 
        
    $order_check->fields['order_total'] > 100 && 
        
    array_search($order_check->fields['payment_module_code'], array('cc')) == FALSE &&
        
    $no_history)) {
            
    $headings_array[] = "YOUR WORDING HERE";
    }

    for (
    $i=0$i sizeof($headings_array); $i++) {
      echo 
    $headings_array[$i];
      if(
    $i+sizeof($headings_array)) {
        echo 
    "<br />";
      }
    }
    ?>

 

 

Similar Threads

  1. Replies: 1
    Last Post: 17 Jun 2014, 07:53 PM
  2. Extra Check boxes at check out
    By issy in forum General Questions
    Replies: 7
    Last Post: 9 Oct 2009, 01:35 PM
  3. What do I edit to remove Check from Check/Money Order payment?
    By GroovyThreads in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 10 Jan 2009, 03:11 AM
  4. Hide stock count and not check for out of stock
    By microbe in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 12 Feb 2008, 12:08 AM

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