, $state ); } /** * Retrieve an estimated number of actions that will be enqueued. * * @access public * * @todo Refactor the SQL query to use $wpdb->prepare(). * * @param array $config Full sync configuration for this sync module. * @return array Number of items yet to be enqueued. */ public function estimate_full_sync_actions( $config ) { global $wpdb; $query = "SELECT count(*) FROM $this->order_item_table_name WHERE " . $this->get_where_sql( $config ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared $count = $wpdb->get_var( $query ); return (int) ceil( $count / self::ARRAY_CHUNK_SIZE ); } /** * Retrieve the WHERE SQL clause based on the module config. * * @access private * * @param array $config Full sync configuration for this sync module. * @return string WHERE SQL clause. */ public function get_where_sql( $config ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable return '1=1'; } /** * Add WooCommerce options to the options whitelist. * * @param array $list Existing options whitelist. * @return array Updated options whitelist. */ public function add_woocommerce_options_whitelist( $list ) { return array_merge( $list, self::$wc_options_whitelist ); } /** * Add WooCommerce constants to the constants whitelist. * * @param array $list Existing constants whitelist. * @return array Updated constants whitelist. */ public function add_woocommerce_constants_whitelist( $list ) { return array_merge( $list, self::$wc_constants_whitelist ); } /** * Add WooCommerce post meta to the post meta whitelist. * * @param array $list Existing post meta whitelist. * @return array Updated post meta whitelist. */ public function add_woocommerce_post_meta_whitelist( $list ) { return array_merge( $list, self::$wc_post_meta_whitelist ); } /** * Add WooCommerce comment meta to the comment meta whitelist. * * @param array $list Existing comment meta whitelist. * @return array Updated comment meta whitelist. */ public function add_woocommerce_comment_meta_whitelist( $list ) { return array_merge( $list, self::$wc_comment_meta_whitelist ); } /** * Adds 'revew' to the list of comment types so Sync will listen for status changes on 'reviews'. * * @access public * * @param array $comment_types The list of comment types prior to this filter. * return array The list of comment types with 'review' added. */ public function add_review_comment_types( $comment_types ) { if ( is_array( $comment_types ) ) { $comment_types[] = 'review'; } return $comment_types; } /** * Stop comments from the Action Scheduler from being synced. * https://github.com/woocommerce/woocommerce/tree/e7762627c37ec1f7590e6cac4218ba0c6a20024d/includes/libraries/action-scheduler * * @since 7.7.0 * * @param boolean $can_sync Should we prevent comment data from bing synced to WordPress.com. * @param mixed $comment WP_COMMENT object. * * @return bool */ public function filter_action_scheduler_comments( $can_sync, $comment ) { if ( isset( $comment->comment_agent ) && 'ActionScheduler' === $comment->comment_agent ) { return true; } return $can_sync; } /** * Whitelist for options we are interested to sync. * * @access private * @static * * @var array */ private static $wc_options_whitelist = array( 'woocommerce_currency', 'woocommerce_db_version', 'woocommerce_weight_unit', 'woocommerce_version', 'woocommerce_unforce_ssl_checkout', 'woocommerce_tax_total_display', 'woocommerce_tax_round_at_subtotal', 'woocommerce_tax_display_shop', 'woocommerce_tax_display_cart', 'woocommerce_prices_include_tax', 'woocommerce_price_thousand_sep', 'woocommerce_price_num_decimals', 'woocommerce_price_decimal_sep', 'woocommerce_notify_low_stock', 'woocommerce_notify_low_stock_amount', 'woocommerce_notify_no_stock', 'woocommerce_notify_no_stock_amount', 'woocommerce_manage_stock', 'woocommerce_force_ssl_checkout', 'woocommerce_hide_out_of_stock_items', 'woocommerce_file_download_method', 'woocommerce_enable_signup_and_login_from_checkout', 'woocommerce_enable_shipping_calc', 'woocommerce_enable_review_rating', 'woocommerce_enable_guest_checkout', 'woocommerce_enable_coupons', 'woocommerce_enable_checkout_login_reminder', 'woocommerce_enable_ajax_add_to_cart', 'woocommerce_dimension_unit', 'woocommerce_default_country', 'woocommerce_default_customer_address', 'woocommerce_currency_pos', 'woocommerce_api_enabled', 'woocommerce_allow_tracking', 'woocommerce_task_list_hidden', 'woocommerce_onboarding_profile', ); /** * Whitelist for constants we are interested to sync. * * @access private * @static * * @var array */ private static $wc_constants_whitelist = array( // WooCommerce constants. 'WC_PLUGIN_FILE', 'WC_ABSPATH', 'WC_PLUGIN_BASENAME', 'WC_VERSION', 'WOOCOMMERCE_VERSION', 'WC_ROUNDING_PRECISION', 'WC_DISCOUNT_ROUNDING_MODE', 'WC_TAX_ROUNDING_MODE', 'WC_DELIMITER', 'WC_LOG_DIR', 'WC_SESSION_CACHE_GROUP', 'WC_TEMPLATE_DEBUG_MODE', ); /** * Whitelist for post meta we are interested to sync. * * @access private * @static * * @var array */ private static $wc_post_meta_whitelist = array( // WooCommerce products. // See https://github.com/woocommerce/woocommerce/blob/8ed6e7436ff87c2153ed30edd83c1ab8abbdd3e9/includes/data-stores/class-wc-product-data-store-cpt.php#L21 . '_visibility', '_sku', '_price', '_regular_price', '_sale_price', '_sale_price_dates_from', '_sale_price_dates_to', 'total_sales', '_tax_status', '_tax_class', '_manage_stock', '_backorders', '_sold_individually', '_weight', '_length', '_width', '_height', '_upsell_ids', '_crosssell_ids', '_purchase_note', '_default_attributes', '_product_attributes', '_virtual', '_downloadable', '_download_limit', '_download_expiry', '_featured', '_downloadable_files', '_wc_rating_count', '_wc_average_rating', '_wc_review_count', '_variation_description', '_thumbnail_id', '_file_paths', '_product_image_gallery', '_product_version', '_wp_old_slug', // Woocommerce orders. // See https://github.com/woocommerce/woocommerce/blob/8ed6e7436ff87c2153ed30edd83c1ab8abbdd3e9/includes/data-stores/class-wc-order-data-store-cpt.php#L27 . '_order_key', '_order_currency', // '_billing_first_name', do not sync these as they contain personal data // '_billing_last_name', // '_billing_company', // '_billing_address_1', // '_billing_address_2', '_billing_city', '_billing_state', '_billing_postcode', '_billing_country', // '_billing_email', do not sync these as they contain personal data. // '_billing_phone', // '_shipping_first_name', // '_shipping_last_name', // '_shipping_company', // '_shipping_address_1', // '_shipping_address_2', '_shipping_city', '_shipping_state', '_shipping_postcode', '_shipping_country', '_completed_date', '_paid_date', '_cart_discount', '_cart_discount_tax', '_order_shipping', '_order_shipping_tax', '_order_tax', '_order_total', '_payment_method', '_payment_method_title', // '_transaction_id', do not sync these as they contain personal data. // '_customer_ip_address', // '_customer_user_agent', '_created_via', '_order_version', '_prices_include_tax', '_date_completed', '_date_paid', '_payment_tokens', '_billing_address_index', '_shipping_address_index', '_recorded_sales', '_recorded_coupon_usage_counts', // See https://github.com/woocommerce/woocommerce/blob/8ed6e7436ff87c2153ed30edd83c1ab8abbdd3e9/includes/data-stores/class-wc-order-data-store-cpt.php#L539 . '_download_permissions_granted', // See https://github.com/woocommerce/woocommerce/blob/8ed6e7436ff87c2153ed30edd83c1ab8abbdd3e9/includes/data-stores/class-wc-order-data-store-cpt.php#L594 . '_order_stock_reduced', // Woocommerce order refunds. // See https://github.com/woocommerce/woocommerce/blob/b8a2815ae546c836467008739e7ff5150cb08e93/includes/data-stores/class-wc-order-refund-data-store-cpt.php#L20 . '_order_currency', '_refund_amount', '_refunded_by', '_refund_reason', '_order_shipping', '_order_shipping_tax', '_order_tax', '_order_total', '_order_version', '_prices_include_tax', '_payment_tokens', ); /** * Whitelist for comment meta we are interested to sync. * * @access private * @static * * @var array */ private static $wc_comment_meta_whitelist = array( 'rating', ); }