Whey I tried to delete products using WP-CLI then products only in default language were deleted. Products in other languages could not be deleted using wp post delete. I used the following command:
wp post delete $(wp wc product list --user=1 --format=ids --per_page=10) --force
More information about deleting WooCommerce products using wp-cli can be found there.
In order to delete products in all languages this needs to be checked: WPML → Settings → “When deleting a post, delete translations as well”.
Ma ei ole siin pikalt koolist kirjutanud aga kool on saanud läbi. Sügissemestril (01.2023) kaitsesin lõputöö ja üleeile (22.06.23) oli lõpuaktus.
Arendaja töökogemuse sain kahes teenusettevõttes (Net Group, Lumav Commerce) aga leidsin, et teenusettevõttes arendajana töötamine mulle ei sobi. Toote-ettevõttes töötamise kogemust mul ei ole. Hetkel toimetan enda projektidega (mõned e-poed, üks API teenus, mõned hobiprojektid).
Overview of WooCommerce CLI can be found here and examples here.
Delete shop order by ID, need to add user id that has permissions to delete orders.
wp wc shop_order delete <id> --user=1
Delete orders where date is older than…
for id in $(wp db query "SELECT id FROM wp_posts WHERE post_date < '2021-01-01' AND post_type='shop_order'" --skip-column-names); do wp wc shop_order delete $id --user=1 --force=1; done
Yes, I did it. I imported new images with every product import so now I have 15000+ images in my media library.
for id in $(wp db query "SELECT id FROM wp_posts WHERE post_date <= '2023-03-20' AND post_date >= '2023-03-15' AND post_type='attachment' AND post_parent=0 AND post_author NOT IN(1,4)" --skip-column-names); do wp post delete --force $id; done
This is the wp cli command that does the job. I found it here.
Just to see how many images will be deleted you can use following query:
wp db query "SELECT COUNT(id) FROM wp_posts WHERE post_date <= '2023-03-20' AND post_date >= '2023-03-01' AND post_type='attachment' AND post_parent = 0 AND post_author NOT IN (1,4)"
You can modify post_author IDs and date ranges as you like. For testing you can as LIMIT parameter to the query.
In Zone webhosting I have several apps under one account. WordPress websites use PHP 7.4 (as WP does not support php 8). But my Laravel apps use PHP 8.
I can choose php version for server. For example:
laravel-app.mydomain.com – this uses php 8.0
wordpress.mydomain.com – this uses php 7.4
If I need to use command line interface (cli) then php version is always the same that I have set for my main domain settings. If I need to use specific PHP version in cli then I need PHPRC prefix before command of export PHPRC in the beginning of the bash script.
As it is impossible to find it on Play Store I will leave it here. The app is called Minimalist Pomodoro Timer. It has dark mode, no ads.
Every other Pomodoro times on Play Store is crap and can be avoided. Just use this.
At some point
var_dump in Postman started printing HTML instead of json and made debugging experience worse. I used php artisan serve and suspected that my CLI php is using xdebug. This advice I found helpful.
sudo phpdismod -s cli xdebug – to disable xdebug
sudo phpenmod -s cli xdebug – to enable xdebug
This is how you can disable and enable xdebug from command line. After this that <pre> thing should go away from Postman responses.
I need to test helper method that accepts Illuminate\Database\Eloquent\Collection as a parameter. But I can not figure out how to prepare it inside a unit test. My logic says it should be simple to create Collection from assoc array. But I just can’t get it to work.
At the moment, not to get stuck, I will probably use feature testing (because if feature (API endpoint) works then probably my helper method also works). Though, it feels stupid workaround.
I spend my time so that you don’t have to.
If you are getting the response “No tests executed” from
php artisan test then please check that your test classes have their names in singular. ContactTest instead of ContactTests.
I spent like 3h to figure out why my Feature tests don’t run from command line while working well in phpStorm. The reason was that my class names were in plural.
In phpStorm see Settings -> PHP -> Test Frameworks -> Test Runner. Check if you have default configuration file phpunit.xml checked. No need to change anything in this file.
.env.testing and copy whole DB_ block from
.env (not just parts that are different). Change values to your test database values.
php artisan config:clear which will clear configuration cache.
Everything should work 🙂
I spent several hours figuring it out. Hopefully you don’t.