Specify the number of args you want to pass to hook function…
add_action('woocommerce_add_to_cart', array( &$this, 'add'), 10, 2);
in this case I am passing a 2…the second arg is the product_id…
Now pick up the product_id here like this…
public function add($instance, $product_id){
GLOBAL $somevar;
Related Posts:
- Use wc_enqueue_js only on specific pages – nested add_action
- How do I remove an action hook inside a class that is called by another class?
- add_meta_boxes action with refresh on save
- How to Remove a Filter from the Admin List Table?
- How to access function from outside of a class within this class in WP plugin?
- action hook wp_head higher priority as all other plugins/hooks
- woocommerce subscriptions – get expiration date [closed]
- Adding Default Settings to Theme My Login plugin
- Automated Cart Update With Alert Box Each Time
- WooCommerce/WordPress: how hide entire table form after submit (Admin Dashboard)?
- Trying to place a custom field after the total section in the checkout page in woocommerce
- How to auto fetch customer details in Woocommerce in checkout page
- Adding widgets to my plugin page instead of WordPress dashboard
- I want to add custom add to cart link [closed]
- Adding function to Genesis genesis_header [closed]
- Extend Woocommerce Widget Class – WC_Widget_Product_Categories
- Change product_base programmatically
- Can a plugin redirect product page based on IF condition?
- Display attribute on shop page after the title
- WordPress WP_Query without query GET parameters
- Where to copy woocommerce files to in my custom theme to avoid editing the core plugin?
- Action Hook Inside WordPress Plugin Shortcode
- custom post type with role Vendor
- Add a custom WooCommerce settings tab with sections
- Payment field disappears on custom Paypal plugin
- I am having errors with checkout on wordpress
- product_type_options get saved value [closed]
- Use PHP Class in WordPress functions
- How can I update the price when someone enters postcode or zip code in woocommerce checkout page?
- Looping through and combining calls to Woocommerce REST API
- How to import woocommerce custom fields data into another site?
- Submit to itself don’t work
- How to execute add_action() function from custom plugin to Crontrol plugin or do_action()?
- How to add custom checkout field in user details mail template
- How keep woocommerce users separeted in multisite install and keep admins on network
- Custom field fetch error on woocommerce pdf invoice
- Woocommerce Convert existing order to the cart
- Too few arguments – wp_login action
- How to change product SKU’s in bulk with a plugin
- Woocommerce Payment Method Change
- Can not add admin notices from the edit_user_profile_update hook (notices not being displayed)?
- How to display a custom product field value of a specific category on a Woo Commerce checkout page?
- How to pass argument to add_action while the method is inside a class?
- Personalize checkout text
- Can’t upload CSV file to plugin directory using custom upload form in admin panel
- wordpress frontend editor to add extra css to website
- CSS change in woo commerce Place Order Text [closed]
- Validate and Sanitize WP REST API Request using WP JSON Schema?
- Woocommerce – get_items() returns empty array
- How do I run code every 24 hours?
- how to Update 15k products on plugin activation with meta_option
- Disable if there are no children – Woocommerce
- WooCommerce – Moving Product Price to the Left of Add to Cart Button [closed]
- Woocommerce Product_cat for current category page
- Exclude product attributes from taxonomy terms loop
- WP All Import / Update stock quantity from multiple XML files
- woocommerce related product title length
- Changing the order of custom fields in the dashboard for Woocommerce variable products [closed]
- woocommerce wc_create_order(); is creating multiple orders instead of one?
- Create a package of products as one Item in woocommerce?
- Why does my settings form redirect to the homepage?
- Using admin-post.php for admin form but it directs me to admin-post.php white screen
- Woocommerce: remove total sum from new order’s email [closed]
- Include js script ONLY on woocommerce product category pages? [closed]
- Set default Database Storage Engine when creating tables with plugins?
- Hooks for post saving make a post-new.php to load latest post’s data
- WP_Query multiple post results
- Convert Featured products loop into Recent products loop?
- fetch woocommerce product with custom taxonomy
- Custom Registration username_exists / email_exists
- How can I search all plugins for composer’s vendor/autoload.php?
- How can I display Custom Post type Custom Columns and its Content in a Dashboard Widget?
- Alter Woocommerce product archive structure
- Have Woocommerce show product price if id, when not logged in
- After disabling WPML multi currency, the currency is still handled by the WPML
- How do i wrap woocomerce attribute in list?
- Removing files programmatically
- How to override a plugins script
- WooCommerce: Display product categories to make IF statement
- WordPress site with embedded menu – gives You don’t have permission to access /wp-content/themes/xxx/taxonomy-redirect.php on this server
- Can I remove or edit an include() from a function with a filter?
- Call to undefined function error in plugin
- Adding Additional Variables on Menus Page
- Dynamically adding filters
- How do I make this Metabox show current DB value?
- WooCommerce “Checkout Now” button [closed]
- custom plugin with upload files does not work
- Custom Taxonomy Select Menu: Setting default option value?
- Removed jQuery script from header.php , any problems?
- Execute Jquery when a specific page in my plugin is loading
- How can I get plugin meta data without knowing the plugin folder?
- Using flickr api in custom wordpress plugin
- How to pass hook variable to function?
- Toolbar Hidden in a Virtual Page
- PHP: How to access db the right way in plugin?
- What is the difference between Null vs Empty (Zero Length) string?
- select a single val though a table in wordpress
- calling admin-ajax.php from admin-ajax.php
- Submit form to db
- Get category id when SEO URL is turned on