woocommerce / bookings-helper

This extension is a WooCommerce Bookings helper which helps you to troubleshoot bookings setup easier by allowing you to quickly export/import product settings.
32 stars 6 forks source link

Add wp cli support #33

Closed ravinderk closed 1 year ago

ravinderk commented 1 year ago

Description

This pull request implements the WP CLI command to export and import booking products and global availability rules.

This solution is backward compatible, which means you can import files generated from the user interface with wp cli command and the same for exported files with wp cli command.

Closes #32

Tests

You should be able to use the following command, and the result should be as expected. These wp cli commands should not generate any regression for the user interface. You should be able to import files from the user interface generated from the wp cli and vice versa. You should be able to import files generated from the booking product edit option Edit product -> Export.

# Export all products
wp bookings-helper export-products --all --dir=/absolute/path/to/directory/

# Export specific products
wp bookings-helper export-products --products="1,2" --dir=/absolute/path/to/directory/

# Export all products with global availability rules
wp bookings-helper export-products --all --with-global-rules

# Import all products
wp bookings-helper import-products --file=/absolute/path/to/file

# Export global availability rules
wp bookings-helper export-global-availability-rules --dir=/absolute/path/to/directory/

# Import global availability rules
wp bookings-helper import-global-availability-rules --file=/absolute/path/to/directory/

# Import all products with global availability rules
wp bookings-helper import-product --file=/absolute/path/to/file --with-global-rules

Noticeable Changes

Changes

Add - WP-CLI command to import and export booking products and global availability rules.

Release action items

faisal-alvi commented 1 year ago

@ravinderk is this ready for review? Seems like you are fixing phpcs errors.

ravinderk commented 1 year ago

@ravinderk, is this ready for review? It seems like you are fixing phpcs errors.

@faisal-alvi PHPCS issues have been fixed. I left a few errors intentionally, so we remember to resolve them.

ravinderk commented 1 year ago

@faisal-alvi

  1. Done
  2. Done
  3. Done
  4. I did not find the logic that includes global availability rules in exported JSON data. I don't know whether this option works as intended.
  5. You are getting an error because I did not add support to import wp cli generated zip file from the user interface. But I can see that this will happen occasionally, so I implement support.
faisal-alvi commented 1 year ago

@ravinderk as per our discussion, you will work on importing global rules along with the product zip in CLI. Please ping me once this is ready for review.

ravinderk commented 1 year ago

@faisal-alvi pull request is ready to review.

ravinderk commented 1 year ago

@faisal-alvi Issues you reported have been fixed. Let's discuss it before you start testing.

faisal-alvi commented 1 year ago

@dkotter should we move it to UAT or direct merge it?

dkotter commented 1 year ago

@faisal-alvi This can be in UAT for now and Jeff and I will review in our next UAT session.