I figured out how to do that actually (using your API) but now i am trying to programmatically add some products to cart alongside their corresponding ppom fields can you help me achieve that?
Hi,
Sorry for the late reply, actually PPOM use following WC filter to add to cart the fields
// Adding meta to cart form product page
add_filter ( 'woocommerce_add_cart_item_data', 'ppom_woocommerce_add_cart_item_data', 10, 2);
and here inside inc/woocommerce.php the callback function:
function ppom_woocommerce_add_cart_item_data($cart, $product_id) {
if( ! isset($_POST['ppom']) ) return $cart;
$ppom = new PPOM_Meta( $product_id );
if( ! $ppom->ppom_settings ) return $cart;
// ADDED WC BUNDLES COMPATIBILITY
if ( function_exists('wc_pb_is_bundled_cart_item') && wc_pb_is_bundled_cart_item( $cart )) {
return $cart;
}
// PPOM also saving cropped images under this filter.
$ppom_posted_fields = apply_filters('ppom_add_cart_item_data', $_POST['ppom'], $_POST);
$cart['ppom'] = $ppom_posted_fields;
// ppom_pa($_POST);
// exit;
return $cart;
}
So actually we are saving all key-value pair inside cart['ppom']
globally.