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
- How to set custom cookies before output
- How to remove “out of stock” variation options from size dropdown in woocommerce?
- Woocommerce: How to override core functions in functions.php?
- wordpress custom endpoint multiple params
- Get WooCommerce shipping methods programmatically
- Add a custom text field to WooCommerce admin product data “Variations”
- Add attribute / custom attribute to product in woocommerce
- Insert array data on plugin activation
- Help with some php math in WordPress
- How do I display a user’s previous orders as a select box option on a product?
- Adding nofollow to a PHP generated Nav
- Hide categories that are not used in the post type
- filter default query to show just selected level of child pages in wordpress
- Reload part of checkout on changed shipping method
- Woocommerce related product text
- Set meta field to publish date + 2 weeks
- How to make my custom widget appear within WordPress widgets? Plugin development
- Function works when I don’t login to WordPress but when I login then it doesn’t work
- Incorrect amount of posts returned when filtering related Woo products by custom taxonomy
- Font Awesome changing default WordPress Font
- Should `wp_login` be used since it’s deprecated?
- Download full html page with CSV export plugin
- How to remove coupon dropdown feature
- WordPress redirect redirecting too many times or not at all
- Add html link in functions.php files of the theme
- how to save checkbox data for custom setting?
- Add product to cart for user – WC()->cart->add_to_cart [closed]
- How to Schedule Cronjobs for start of every month and year
- how can i add class or span tag at sprintf?
- Output product category link from WP_Query
- How to get woocommerce orders with get_posts method in a shortcode
- Variation prices breakdown only for single product page
- Best way to use variables in multiple functions?
- Display all categories including sub categories under a list ul
- WP Hook Before a post is created
- Adding new divs with custom classes to products on WooCommerce shop page [closed]
- Get product price in a different currency using WooCommerce Currency Switcher
- Store user form submitted information in post type
- How to get total gross revenue for current month in the woocommerce dashboard status widget
- Add custom attribute to product’s HTML to woocommerce cart page
- Change WooCommerce template for PDF – access to custom field
- How can i style “echo apply_filters”
- Add custom ID attribute to all woocommerce products on archive pages
- How to properly create multiple conditions to redirect users roles to different pages
- Setting at job with shortcode not working
- Run code before WordPress loads and insert data into WP if need be
- How to detect if a revision was made by woocommerce or wordpress?
- Use WP_Query Data In Cookie
- Highlight posts currently being edited on multiple editor site?
- WordPress Plugin Receive a Link
- Add specific phrase after every product title including the discounted price? [closed]
- Setting WooCommerce currency programmatically
- I’m not able to get access $wpdb in my php file in wordpress
- How do I change the Go To Categories link in the term_updated_messages
- Show button in header when product custom field is not empty
- Why a class property becomes empty?
- WordPress 6.1.1 UTF8 Slug Limit Increase
- How to change wp-admin and wp-login urls
- How to add SKU and remove product title from WooCommerce url?
- Load style and script for custom post type metabox
- Permissions error when I use my plugin to delete comments in the front-end
- Product Search in search.php
- using custom pages for myaccount in woocommerce