Hi @rosewoodat5th,
Each campaign our plugin creates is ic-campaign
Custom Post Type and all the information about such campain is saved as post meta the way below:
clear_cart
with yes
/no
values – information if the cart should be cleared before adding the products with the cart link,
redirect_to
with any type of public posts id
, however, its select is limited to page
at the moment,
products
being a serialized multidimensional array with campaign products. Each row is a an array containing the following fields:
product_id
– product’s or variation’s id (integer)
quantity
– the quantity of the products which should be added to the cart (integer)
price
– if the value is >=0 it will be considered as product’s new price to be applied, free if left empty.
To be honest we haven’t planned to implement the campaign import/export functionality yet at this point, however, it seems to be a really useful feature and we added it to our features requests list for the upcoming updates.
I’m afraid that in order to process the links you’ve mentioned you would need to write a dedicated CSV importing mechanism using wp_insert_post
, e.g.,
$post_id = wp_insert_post( [
'post_type' => 'ic-campaign',
'post_status' => 'publish',
'post_title' => 'Example Campaign Name',
'meta_input' => [
'clear_cart' => 'yes',
'redirect_to' => 2,
'products' => [
[
'product_id' => 19,
'quantity' => 1,
'price' => 1.23,
]
],
],
] );`
Kind regards,
Luke