I had a failed customer/order import when I upgraded a WooCommerce site.
Customers are now logging in and seeing orders and customer information for random orders - not their own. It is a catastrophe!
I am thinking that a solution might be to unlink all customers from orders and forcing customers to be manually relinked on request.
Problem is - I have an unverified problem whereby one customer recreated a user and on login, had been "magically" linked to another customers order details - so even creating new users seems to be problematic.
Any suggestions would be helpful.
This is a possible explanation of your problem. The customer for an order is saved in the the wp_postmeta table with the meta_key '_customer_user'. This integer is a reference to 'ID' column of wp_users. I think your import broke this relationship. Did your import change user id's? If so you need to remap all the '_customer_user' meta_values to their corresponding new user ids.
If you want to just unlink orders from customers I would try setting this field to 0 or maybe to 1 which would mean that initial user (sysadmin) would now be the customer for all orders. If you do this remember to keep a record of the original '_customer_user' so you can try and recover the correct id later.
Related
I have a newspaper and would like to register the hits for every news article. I was thinking of tbl_hits with fields ArticleId and sort field timestamp (plus Other attribute fileds for headers, browser type).
However usually i get multiple hits for the same article at theexact same time so I guess I wont be able to register them since I will get duplicate key error.
What primary key + sorting fields would you recommend? Thanks so much.
Problem summary
I am trying to fetch all customers with POSTMAN using the latest woocommerce API (v3):
GET/customers
Yet only a small segment is returned. The number of customers returned is 28 (X-WP-Total) which is much less than the 150+ customers I have in the system.
Do you guys have any ideas on why only a subset of all customers are being returned instead of all? Does this have anything to do with how I configure woocommerce? Or am I just using the API incorrectly?
What i have tried
My goal is to create a small application to look up a customer by phone/email and then fetch the orders he had made.
Calling
GET/customers
Only returns a small subset of all customers and the rest is omitted.
Any customers omitted from the GET/customers will also return an empty array when i for example use
GET/customers?email=...
GET/customers?search=...
The requests returns an empty array on the omitted customers but
works on customers that was not omitted from:
GET/customers
Yet, given a known omitted customer ID, it is possible to look up that customer by sending a request to
GET/customer/{ID}
which does not make sense at all.
The solution is to set:
GET/customers?role=all
I figured that GET/customers only return by default customers whose role is 'customer'.
However, since I also make use of memberships/subscriptions, a customer would automatically get a new role assigned ('subscriber') whenever they opt-in for a membership. That customer would therefore not be included in the response since his role is no longer 'customer'.
Hope this helps anyone who stumbles upon the same problem.
I'm building a commerce site using Drupal Commerce. I've got it going very smoothly now but I've hit a dead end when I'm trying to create a module for handling shipping information and sending it to the shipping company for label printing.
The problem is, that I have created a new tab in an Order page,
admin/commerce/orders/order_id/printlabel
and I can access this page via a tab when I edit an order.
Now, I have no idea how I can pull the order_id number in the module. I have tried almost everything, entity_view, entity_metadata_wrapper, commerce_order.module API, but I have no idea how I can access the id and that is the key. When I get the ID, I can get the shipping information linked to it and I can send this data to the shipping company and save it.I also looked into the ways Commerce does things like combine Payment with Views but it seemed a bit too complicated for me to try so, I'm asking here. I can't get any answers on Drupal's own support forums.
Hope i got your question right.You created a custom menu admin/commerce/orders/*/printlabel where * is the order id of a particular order. You need the order id.
The simplest solution to it is getting it through the arguments or arg(). This is a function that drupal provides to get data from the arguments. For eg
if your url is www.xyz.com/admin/commerce/orders/0001/printlabel & you need order id i.e 0001 you can get it using arg(3).
I am building a website users have to pay for different functions. For example the user have payed for "packet 1" for the current month and it includes "short messages". How can I check, if a user is allowed to send sms? Updating the user/role relations every night or is there anything more dynamic?
You could add custom voter, where you can check if a user is allowed to use certain service. See example here:
http://symfony.com/doc/current/cookbook/security/voters.html
You can create a table in a database which has a foreign key to a table of which contains different packages, a foreign key to your user table and finally a column which indicates the expire date of the package.
If the package is not found for that user and for that expire date then the user is not allowed to send sms.
You can use some other storage procedures but using a database makes most sense.
Basically: You don't want to update anything, you simply want to store certain information like the expire date (and maybe the starting date if you want to change the expire duration) and compare to that selected value.
i am working on a online forum like where anybody whether registered or un-registered user can comment on a particular topic/article etc...
so, when the user (registered/un-registered) leave their comments we have a process for approving by admin which is behind the scene....
so my question is, when the user leave their comments then i want to hold on to their comments till their comments approved by admin or till the session is alive
the same user can leave one comment or many comments to a topic/article...
on the same page i will have different comments leave by other users which are approved by admin...
i would like to know what is the best way to handle?
example:
[some topic here.........................
...................................................]
*comments:*
abc ............................... [pendign approval] //this data will be coming from session
xxxxxxxxxxxxxx......................[approved] //all the approved coming from db
aaaaaaaaaaaaaaaaaa..................[approved]
............
..................
.................
I don't think you should depend session for this. You should probably store the comment status with a different status in the table.
Ex : When a comment is newly posted ,save it to the database with status as 0 / "Pending"
Wen Admin approves, change it to 1/"Approved"
If admin rejects , change it to -1/ "rejected" / delete the record if you dont want to store it any more
When the page loads (for all users/public), get the records filtered by status
SELECT ID,COMMENT FROM COMMENTS WHERE STATUS=1 AND POST_ID=#postId
When the page loads (for all a user who posted the comment), get the records filtered by status ( include pending also now)
SELECT ID,COMMENT FROM COMMENTS WHERE
((STATUS IN =1)
OR (STATUS =0 AND CREATED_BY=#currentUserId))
AND POST_ID=#postId
You will need to allocate anonymous users an account automatically (similar to the registered users ones). When a user registers you can upgrade their account. In this way the same process can be used to display comments from both.