Tips and Tricks HQ Support Portal › Forums › WP eStore Forum › Updating a Date field in wp_estore_tbl
- This topic has 9 replies, 2 voices, and was last updated 13 years, 2 months ago by stitch1z.
-
AuthorPosts
-
August 30, 2011 at 4:56 pm #4189stitch1zMember
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.
August 30, 2011 at 6:08 pm #36013stitch1zMemberMy 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.
August 30, 2011 at 11:59 pm #36014stitch1zMemberOkay, I am almost there…
$product_name = $wpdb->escape(stripslashes($cart_item_data_name));
$sale_price = $current_cart_item;
$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!
August 31, 2011 at 2:26 am #36015adminKeymasterI 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.
August 31, 2011 at 2:31 am #36016stitch1zMemberLong 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!
August 31, 2011 at 4:43 am #36017stitch1zMemberWould this work?
$product_description = $wpdb->get_row(“SELECT description FROM $products_table_name WHERE id = ‘$cart_item_number'”, OBJECT);
August 31, 2011 at 5:10 am #36018stitch1zMemberNope that’s not doing it. Any suggestions?
August 31, 2011 at 5:26 am #36019adminKeymasterI 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;August 31, 2011 at 5:54 am #36020stitch1zMemberStrange. 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!
August 31, 2011 at 6:54 pm #36021stitch1zMemberI got it figured out. Thank you for all of your help. Again. lol
-
AuthorPosts
- You must be logged in to reply to this topic.