bobbingwide / oik-clone

Clone content between sites
https://www.oik-plugins.com/oik-plugins/oik-clone-clone-your-wordpress-content/
GNU General Public License v2.0
5 stars 0 forks source link

Investigate cloning of WooCommerce products #44

Open bobbingwide opened 4 years ago

bobbingwide commented 4 years ago

For WP-a2z we need WooCommerce products in multiple sites. They’re needed to give live examples for blocks which use them. The existing cloning logic is not enough.

Expected result

When a Product is cloned then it shouldn't need editing on the target server

Actual result

Not all the required data is created on the target. This can lead to blocks that rely on WooCommerce data to fail to produce the expected output.

One example is the woocommerce/product-on-sale block. For this block to work it appears to need the data that WooCommerce populates in the wc_product_meta_lookup table.

Another example is that attachments, such as download files, are not cloned. This isn't really a problem for WP-a2z since the products are mostly examples. We don't expect any orders to be fulfilled.

Proposed solution

Determine the best way to copy WooCommerce products and attempt to apply the same logic in cloning.

Hints:

bobbingwide commented 4 years ago

There's a further complication when it comes to cloning certain WooCommerce blocks. In the Products by Attributes block there are attributes representing the selected Product attributes. These values are stored in more complex structures than catered for in #38. Cloning would have to take into account the mapping of the id attrs

<!-- wp:woocommerce/products-by-attribute 
{"attributes":[{"id":411,"attr_slug":"pa_size"},{"id":410,"attr_slug":"pa_size"}],
"editMode":false} /-->\n\n
bobbingwide commented 4 years ago

The Products by Category block has an attr called categories.

<!-- wp:woocommerce/product-category {"categories":[322,320]} /-->
bobbingwide commented 4 years ago

The Products by Tag block has an attr called tags.

<!-- wp:woocommerce/product-tag {"tags":[323]} /-->
bobbingwide commented 4 years ago

The Top Rated Products block includes a categories filter, which may be an empty array.

<!-- wp:woocommerce/product-top-rated {
"categories":[],
"contentVisibility":{"title":true,"price":true,"rating":true,"button":true}} /-->
bobbingwide commented 4 years ago

One example is the woocommerce/product-on-sale block. For this block to work it appears to need the data that WooCommerce populates in the wc_product_meta_lookup table.

Q. How do we correct this after cloning?