J
J
John2022-04-15 11:46:21
WordPress
John, 2022-04-15 11:46:21

How to sell digital keys?

Is it possible to implement the sale of digital keys through WordPress so that it would be possible to download a certain number of keys in one go at once, and when buying, only one was issued to the buyer, and the number in stock decreased, so that the same key would not be issued to different people. Maybe there are plugins to implement this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
AlexNest, 2022-04-15
@divi1

We have already suggested a variant with commercial plug-ins above. If this does not suit you, then you can write yourself.
I will not describe the full development cycle, I will only point out those points that were asked in the question and, in fact, are key, about protection, code optimization, database structures, and so on, think for yourself.
1. Organize the storage of keys.
Since keys are by definition unique but activate a specific product, they must be stored in a separate table linked to the product table via a foreign key. What other fields will be in this table - depends only on the needs of the customer.
2.Organize the sample so that only one buyer can buy one key.
I don’t know how wordpress works, but there is a construction in sql *select ... for update, which blocks further fetching of rows until the current transaction ends (including both locking and changing the necessary data).

simple example
START TRANSACTION;
 
  -- заблокировать нужное
  SELECT value FROM counters WHERE id = 1 FOR UPDATE;
 
   -- увеличить значение.
  UPDATE counters SET value = value + 1 WHERE id = 1;
 
  COMMIT;

How exactly to separate the sold and not sold goods - again, it's up to you, there are several options.
3. Download keys.
There is such a wonderful format as csv. As for me, it suits the best for loading a large amount of data. There should be plugins to work with it. On the other hand, this is more a question of the format in which you will receive them, and how to upload them to the database will already depend on this.
* - definitely exists in mysql and postgresql (and, in theory, any other databases that support transactions)

I
Igor Markin, 2022-04-15
@iggor-markin

There are paid solutions. I will not provide specific links. You can google for wordpress keys shop plugin .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question