All Collections
Omni Channel
WooCommerce
Speed Up WooCommerce Scan Product
Speed Up WooCommerce Scan Product

Insert source code to speed up the process of scanning WooCommerce products on marketplace.dealpos.app

Marissa Arnindia avatar
Written by Marissa Arnindia
Updated over a week ago

When integrating POS with WooCommerce, requires product synchronization between POS and WooCommerce. Sometimes after we successfully upload or want to check the synchronization of our products between POS and WooCommerce, we need to do a Scan Product to check the synchronization status updates.

When DealPOS accesses product data from WooCommerce, WooCommerce will provide a large amount of property data, this causes the Scan Channel for WooCommerce products on the marketplace.dealpos.app to be very long because many properties are not used and are also taken. Therefore we need to do the settings by inserting a few lines of code in the WooCommerce website. For detailed steps, you can check the steps below.

Step 1. Go to Appearance Menu, then Click Theme Editor

WordPress configuration to speedup DealPOS Performance

Step 2. Select and Edit Theme

Select the theme you want to use, then click edit theme Function (function.php).

WordPress configuration to speedup DealPOS Performance (2)

Step 3. Insert the Code

Customize code for SpeedUp DealPOS Performance

You can copy the code from here :

/*  
* Add fillter to adjust webhook/api response when get all product from Marketplace Integration.
* References: https://stackoverflow.com/questions/56678243/how-to-fetch-specific-json-field-from-woocommerce-rest-api
/* This function will have 2 workarounds
* 1. You can get spesific fields by adding parameters (products?per_page=100&page=1&fields=id,name)
* 2. You can get all fields by not adding any parameters (products?per_page=100&page=1)
*/

add_filter( 'woocommerce_rest_prepare_product_object', 'my_woocommerce_rest_prepare_product_object', 10, 3 );
function my_woocommerce_rest_prepare_product_object( $response, $object, $request )
{

$data = $response->get_data();
$newdata = [];

if ($request['fields'] != null)
{
foreach ( explode ( ",", $request['fields'] ) as $field )
{
$newdata[$field] = $data[$field];
}
$response->set_data( $newdata );
}

return $response;
}

Source / Reference :


You might also like to read these articles below :


If you are a retail business owner and sell products offline and online stores. you can use DealPOS to manage products, inventory, and orders on one platform. DealPOS made it easier for you to sell omnichannel. Try DealPOS for 14 days for free now :

dealpos-trial-indonesia

Did this answer your question?