WooCommerce batched add to cart functionality
Budget: €30 – €250 EUR
1. For this project you will need a clean WP install with WooCommerce installed.
2. Add 2000 fake products with the plugin fakerpress (make sure you also add _price and _regular_price meta; all prices can be set to 10 or whatever number)
3. Add an option in the database (with WP CLI or whatever), with option name "cart123" and as value a serialized array of any 1000 product IDs you just generated.
4. Make a template file (template name can be "SB Scan")
5. In the new template file get the cart123 option
6. Now I will describe what needs to happen, and you can decide how to make it: so now (after step 5) we have 1000 product IDs. I want those added to the WooCommerce cart with ajax (prefer plain JS but jQuery is fine). But don't do 1 ajax call per product. Batch them, because each ajax call will load WP and loading WP a 1000 times is not efficient. Also don't do 1 ajax call and then process all IDs with PHP, because that will time out on our server (we will actually do many more product IDs). So I was thinking of doing like 200 products per batch. So that will be 1000 / 200 (=5) ajax calls and then the ajax call will call a PHP function that loops the IDs and adds to the cart. On the 1st iteration (ajax call), the PHP must do a WC()->cart->empty_cart(); so you have to track/determine in PHP if this is the 1st ajax call. And to add the product in PHP, do this:
WC()->cart->add_to_cart( $product_id, 1 );
usleep( 100000 ); // leave this in
On the page, make a simple progress bar that updates after each ajax call, so the percentage progress can be seen.
When the ajax calls are done, add the text "Done adding to cart" under the progress bar. Then timeout for 5 seconds and after that do a redirect to the cart URL (don't hard code the cart URL, but get it somehow).
Please let me know if you would do another number for the batch size (so in stead of 200) or if you would stick to 200 (this is so I know you read this text to the end).
You can quote a fixed price or hourly price (if hourly, please estimate how long it will take)
2. Add 2000 fake products with the plugin fakerpress (make sure you also add _price and _regular_price meta; all prices can be set to 10 or whatever number)
3. Add an option in the database (with WP CLI or whatever), with option name "cart123" and as value a serialized array of any 1000 product IDs you just generated.
4. Make a template file (template name can be "SB Scan")
5. In the new template file get the cart123 option
6. Now I will describe what needs to happen, and you can decide how to make it: so now (after step 5) we have 1000 product IDs. I want those added to the WooCommerce cart with ajax (prefer plain JS but jQuery is fine). But don't do 1 ajax call per product. Batch them, because each ajax call will load WP and loading WP a 1000 times is not efficient. Also don't do 1 ajax call and then process all IDs with PHP, because that will time out on our server (we will actually do many more product IDs). So I was thinking of doing like 200 products per batch. So that will be 1000 / 200 (=5) ajax calls and then the ajax call will call a PHP function that loops the IDs and adds to the cart. On the 1st iteration (ajax call), the PHP must do a WC()->cart->empty_cart(); so you have to track/determine in PHP if this is the 1st ajax call. And to add the product in PHP, do this:
WC()->cart->add_to_cart( $product_id, 1 );
usleep( 100000 ); // leave this in
On the page, make a simple progress bar that updates after each ajax call, so the percentage progress can be seen.
When the ajax calls are done, add the text "Done adding to cart" under the progress bar. Then timeout for 5 seconds and after that do a redirect to the cart URL (don't hard code the cart URL, but get it somehow).
Please let me know if you would do another number for the batch size (so in stead of 200) or if you would stick to 200 (this is so I know you read this text to the end).
You can quote a fixed price or hourly price (if hourly, please estimate how long it will take)