• Resolved alexwaterfront

    (@alexwaterfront)


    Hi, i am developing a plugin and i want to fetch all the ppom fields assigned to a product. How can i do that please?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter alexwaterfront

    (@alexwaterfront)

    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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Programmatically get product fields’ is closed to new replies.