Tips and Tricks HQ Forum

Support Forum for Tips and Tricks HQ Products

Register or log in - lost password? (Having an issue with the forum login?)

Search the Forum

Tips and Tricks HQ Forum » WP eStore Forum

Updating a Date field in wp_estore_tbl

(10 posts) (2 voices)
  • Started 8 months ago by stitch1z
  • Latest reply from stitch1z
  • Possible Solutions (Related Topics):
    1. eMember - After purchase not updating membership (using PayPal Pro)
    2. Checklist option in Custom Fields for Registration Form
    3. eMember login button "jumps" cursor down to eStore form field in the sidebar
    4. Can not update membership levels
    5. emember - custom field display order not working, change width of field, +more

Tags:

  • database
  • queries
  1. stitch1z
    Member

    Hello there,

    I have written a query to collect sales information from the estore databases, but I need to be able to categorize it by month.

    The most organized way I could present this information is if I could have the wp_estore_tbl update a "date" field when a sale is made. If at all possible, I would like it to only store the month so there won't be thousands of rows.

    I have created the date field in the table, but how do I tell WP Estore to update the month to wp-estore-tbl whenever a purchase is made.

    Thank you very much in advance.

    Posted 8 months ago #
  2. stitch1z
    Member

    My logic was all wrong....

    Better yet (and probably much simpler), how do I tell WP-Estore to update the wp_eStore_sales_tbl with the same "name" and "description" fields that are used in wp_eStore_tbl. That would have me set for my sales reports.

    Thank you again for being so helpful.

    Posted 8 months ago #
  3. stitch1z
    Member

    Okay, I am almost there...

    $product_name = $wpdb->escape(stripslashes($cart_item_data_name));
    $sale_price = $current_cart_item['mc_gross'];

    $updatedb = "INSERT INTO $customer_table_name (first_name, last_name, email_address, purchased_product_id,txn_id,date,sale_amount,coupon_code_used,member_username,product_name,address,phone,subscr_id,purchase_qty,ipaddress,status) VALUES ('$firstname', '$lastname','$emailaddress','$current_product_id','$transaction_id','$clientdate','$sale_price','$coupon_code_used','$eMember_username','$product_name','$address','$phone','$subscr_id','$cart_item_qty','$customer_ip','$status')";
    $results = $wpdb->query($updatedb);

    $updatedb2 = "INSERT INTO $sales_table_name (cust_email, date, time, item_id, sale_price, name, description) VALUES ('$emailaddress','$clientdate','$clienttime','$current_product_id','$sale_price','$product_name','$product_description')";
    $results = $wpdb->query($updatedb2);

    Okay, I have the product name updating in my sales table now. ALL I need from you now is to tell me how to set "$product_description" to deliver the description of a product.

    Like:
    $product_name = $wpdb->escape(stripslashes($cart_item_data_name));

    Thank you again!

    Posted 8 months ago #
  4. admin
    Key Master

    I am not sure why you are trying to add the description into the sales table. A product description is already present in the products table (its not like the product description is going to change when the sale happens). So all you need to do is query the products table with the PRORUCT ID (this ID is unique and can be used to reference across tables) and retrieve the description from there when you need it.

    Posted 8 months ago #
  5. stitch1z
    Member

    Long story short, I am getting an error when I try to query both tables. I'm doing it right, but I think there is a bug in some of the script I am using to display everything. This is why I had to go this route in the first place.

    If you could possibly tell me how to tell estore to put the product description in the sales table upon each sale, I would be very grateful.

    Thank you again!

    Posted 8 months ago #
  6. stitch1z
    Member

    Would this work?

    $product_description = $wpdb->get_row("SELECT description FROM $products_table_name WHERE id = '$cart_item_number'", OBJECT);

    Posted 8 months ago #
  7. stitch1z
    Member

    Nope that's not doing it. Any suggestions?

    Posted 8 months ago #
  8. admin
    Key Master

    I am assuming you have good understanding of MySQL database and you also have access to WordPress from this script that you are modifying.

    This is what you can use:

    global$wpdb;
    $products_table_name = WP_ESTORE_PRODUCTS_TABLE_NAME;
    $retrieved_product = $wpdb->get_row("SELECT * FROM $products_table_name WHERE id = '$cart_item_number'", OBJECT);
    $product_description = $retrieved_product->description;
    Posted 8 months ago #
  9. stitch1z
    Member

    Strange. Still not sending the description to the sales table.

    To be clear I am altering paypal.php and eStore_post_payment_processing_helper.php so it will send the information to the sales table so the description and name will show up in the sales table when someone makes a purchase, initiating an update.

    The name is sending, I've gotten it that far.

    The code you just gave me didn't pull the description either. I don't know why, though...

    Any other ideas?

    Thank you again! You are very helpful!

    Posted 8 months ago #
  10. stitch1z
    Member

    I got it figured out. Thank you for all of your help. Again. lol

    Posted 8 months ago #

RSS feed for this topic

Reply

You must log in to post.

Tips and Tricks HQ  | WP Shopping Cart  | WP Affiliate Software  | WordPress Membership Plugin