I am not able to run two functions at the same time while using a filter that one of my plugins allow me. Actually I am trying to charge users as per checkboxes selection. But with my code, as given bellow, I am only able to process one payment (woo-commerce product) at a time.

PS: To understand the question more clearly, I am using toolset types plugin for custom fields, cred form & cred commerce plugins to charge for posting ads and woocommerce to process the payment. In my form, I have 2 addons as checkboxes that if users click when posting are charged accordingly.

// Function for urgent-banner
add_action ('cred_commerce_add_product_to_cart','my_hook',10,3);
function my_hook($product_id, $form_id, $post_id)

{
// product id is the current associated product ID
// form_id is the cred commerce form id
// post id is the post created or edited with the current form

if (get_post_meta(get_the_ID(), 'wpcf-urgent-ad', true)) {
$product_id = 687;
//$product_id = 209;
}

return $product_id; 
}

//Another function for Home page slider carousel

add_action ('cred_commerce_add_product_to_cart','my_hookc',9,3);
function my_hookc($product_id, $form_id, $post_id)

{
// product id is the current associated product ID
// form_id is the cred commerce form id
// post id is the post created or edited with the current form

if (get_post_meta(get_the_ID(), 'wpcf-home-page-carousel', true)) {
$product_id = 209;
}

return $product_id; 
}

Read more here: Using WordPress filter multiple times


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: