If you are syncing prices from your product supplier’s API. The supplier price does not always include your store’s price markup. WP Data Sync plugin it packed with action hooks and filters to make this an easy customization.
In the code example below, we are adding a 10% markup to all prices provided by your data source using the wp_data_sync_{$meta_key}_value
filter. Please note, you can adjust the markup by changing the $markup
value.
Add the code snippet below to your themes function.php
file.
Code Example
/**
* Filter WooCommerce Price Meta Values
*
* Marup all WooCommerce prices by 10%.
*
* @package WPDataSync
*/
// WooCommerce regular price
add_filter( 'wp_data_sync__regular_price_value', 'wp_data_sync_price_markup', 10, 3 );
// WooCommerce sale price
add_filter( 'wp_data_sync__sale_price_value', 'wp_data_sync_price_markup', 10, 3 );
/**
* WP Data Sync Price Markup
*
* @param $price
* @param $post_id
* @param $data_sync
*
* @return mixed
*/
function wp_data_sync_price_markup( $price, $post_id, $data_sync ) {
// Markup value 10%.
$markup = 1.1;
if ( ! empty( $price ) && is_numeric( $price ) ) {
// Add markup to price
$price = floatval( $price ) * $markup;
}
return $price;
}
Get Started
-
Starter Plan
$39.00 / monthMore Info- 10,000 Requests/Month
- Unlimited Data Sources
- Unlimited Websites
- Unlimited Users
Basic Plan
$69.00 / monthMore Info- 40,000 Requests/Month
- Unlimited Data Sources
- Unlimited Websites
- Unlimited Users
Professional Plan
$129.00 / monthMore Info- 150,000 Requests/Month
- Unlimited Data Sources
- Unlimited Websites
- Unlimited Users
Data Source Mapping
$149.00 – $999.00More Info This product has multiple variants. The options may be chosen on the product pageLet us do the mapping for you!!We will map all your data sources for you, so you can move on to other projects that demand your time. One of our experts will map up to 50 fields for you in each data source.