Using WordPress add_filter hook multiple times for addons
-
[ Moderator note: moved to Developing with WordPress. ]
I am not able to run two functions at the same time while using a filter.
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.
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_filter ('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_filter ('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; }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Using WordPress add_filter hook multiple times for addons’ is closed to new replies.