Product Sync module
Learn more about the Product Sync module.
This module syncs the product information to Digital River when any product is created, updated, or deleted. Products can be manually synced from the Admin dashboard via Tools -> Available Tools
Specifications
This module will leverage SKU API provided by Digital River.
Whenever a product in WooCommerce is created, updated, or deleted, this module will call the Digital River SKU API and update the SKU information.
SKU API will also need the ECCN, HS Code, Country of origin, and Tax code. These fields will be added and provided by ProductMetaFields
module.
The ProductSync
module does not manage the addition and validation of required meta fields. That process is managed in the ProductMetaFields
module.
Modify the SKU Request object
To modify the SKURequest
object before sync:
Grab the
SKURequest
object from the filter:add_filter( 'digitalriver.pre_sync_sku_request', 'filter_method' )
The
SKURequest
object will be passed as the first argument tofilter_method()
.Make any changes to the object and then return the object.
Replace the Sync Handler with a custom class
To replace the SyncHandler
with a custom class:
Grab the
SyncHandler
object from the filter:add_filter( 'digitalriver.sync_handler', 'filter_method' )
The
SKURequest
object will be passed as the first argument tofilter_method()
.Swap out the object if necessary and then return the object.
Product Sync Methods
Product Sync class
This class describes the module's entry point.
Method | Args, Returns, and Descriptions |
name | Arg: - Return: string Description: Returns the name of the module |
init | Arg: - Return: void Description: Initializes the module and register necessary hooks |
assets | Arg: String $page_hook Return: void Description: Enqueues the scripts and stylesheets in the |
sync | Arg: int $post_id Return: bool Description: Syncs the product to Digital River and return the status of the sync |
delete | Arg: int $post_id Return: void Description: Deletes the product from Digital River using |
get | Arg: int $post_id Return: SKU Description: Fetches the product from |
sync_status | Arg: - Return: void Description: Gets the sync status of the product. Product ID should always be the parent product ID. |
sync_variations | Arg: Return: void Description: Syncs all variations for variable product |
sync_tool_box | Arg: - Return: void Description: Displays the manual product sync toolbox |
sync_handler | Arg: - Return: ProductSyncHandler Description: Returns an instance of the |
Sync Container class
This class defines all the services required for this module.
Method | Args, Returns, and Descriptions |
__construct | Arg: Return: void Description: Accepts a Dependency Injection container as an argument and assigns it to a container attribute |
define_services | Arg: - Return: void Description: Defines all the classes present within the module |
Sync Meta Box class
This class adds the metabox to the Product Edit screen and contains a button to trigger the product sync action.
Method | Args, Returns, and Descriptions |
init | Arg: - Return: void Description: Initializes the object and registers the necessary hooks for displaying the metabox |
assets | Arg: String $page_hook Return: void Description: Enqueues the scripts and stylesheets in the |
add | Arg: - Return: void Description: Adds the metabox to the product edit page and triggers the render callback |
callback | Arg: - Return: void Description: Displays the metabox contents with the render callback |
Sync Handler class
This class handles the actual sync process between WooCommerce and Digital River.
Method | Args, Returns, and Descriptions |
init | Arg: Return: void Description: Constructs the object by passing its dependencies |
upsert | Arg: - Return: bool Description: Uses the |
delete | Arg: - Return: void Description: Uses the |
get | Arg: - Return: SKU Description: Uses the |
product | Arg: Return: Description: Sets the product to sync and returns the SyncHandler object and is useful for chaining methods |
sku_request | Arg: - Return: SKURequest/null Description: Prepares the |
Endpoint/Sync class
This class exposes the /digitalriver/v1/sync
endpoint and syncs products to Digital River when a request is sent to that endpoint.
Method | Args, Returns, and Descriptions |
__construct | Arg: Return: void Description: Constructs the object by passing its dependencies |
init | Arg: - Return: void Description: Makes a call to the |
register | Arg: - Return: void Description: Registers the |
sync_products | Arg: Return: Description: Initiates the product sync with the REST route callback |
Last updated