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
- Retrieve multiple values passed to a single attribute in a shortcode
- How can I remove “Proudly powered by WordPress” from twentyeleven without modifying footer.php?
- How to change date language without changing the entire site language?
- Using Cookie Data For WP_Query Loop
- Why when I instantiate wp_error in a validation method my user registration method stops working?
- Appending meta value onto post content in WordPress during save_post
- Problem with WordPress Ajax form
- Using Font Awesome as post thumbnail
- admin-ajax.php responding with 0
- How to use return in my custom function instead of echo
- How to prevent those PHP variables from being cached on WordPress?
- How to restrict wp generate attachment metadata() to certain intermediate image sizes
- Setting All Drafts to ‘exclude-from-catalog’ in WooCommerce
- WordPress php filter admin_body_class not working
- Same log message keeps on printing to debug.log file thousand of times
- Append HTML Using Shortcode
- dividing sub-categories by parent category – WordPress
- How to get all shipping rates and costs without session in woocommerce?
- how to fix error “called incorrectly, should not be accessed directly”?
- Execute long and heavy processes
- Validation algorithm in checkout field
- How can I hide that I Use WordPress (with W3 Total Cache)
- Override a function defined in wp-includes/comment-template.php
- Replace Woocommerce “add to cart” to be “Download” button [closed]
- Is it possible to define variables in a wordpress shortcode, and then call the shortcode using a specific variable?
- How to remove the message ‘We could not find any results for your search’ without changing template files and without adding posts/pages?
- Custom meta box values are not getting saved for my custom post type
- WooCommerce pages looks unstyled
- How to display a custom product field value of a specific category on a Woo Commerce checkout page?
- Personalize checkout text
- Execute Jquery when a specific page in my plugin is loading
- Modify WooCommerce used to get all orders in dashboard
- Add Custom Category Description When Empty
- I am having issue in divi woocomerce checkout module. (DIVI theme)
- Add a product category to a specific product via a button
- WordPress can’t use ZipArchive
- Display div if category has a specific parent
- Only the first image uploads
- global $product is empty string when passed into function
- WordPress loading progess – wp-blog-header.php
- Custom plugin: how do I call a PHP file if settings option is set to true?
- Trying to use a variable to set image width
- How to identify which php file a plugin is using on page load?
- dashboard widget form not submit mails
- I want to hide “sold by” on certain pages with id page 43
- get_filtered_term_product_counts – Get product terms if any products
- register_setting not save checkbox
- How does one make a URL return dynamic JSON with custom Content Type?
- Need to forward Data from WooCommerce Webhook sent to same site WordPress REST API custom endpoint
- Add Product Permalink in woocommerce admin order page
- WooCommerce Custom Tab with ACF Repeater Field
- add menu page in loop menu order
- defined (‘ABSPATH’) false after AJAX post to other PHP-file
- Custom post type single page return to listing page
- WordPress rewrite question
- Using Nonce for my Form
- Create new folder and upload files to custom folder via wp_handle_upload
- Unable to show 4 products in a row
- Getting custom field data from cart page to checkout page in woocomerce [closed]
- JQuery UI Autocomplete showing as bullets
- “Joined in” or “Member since” displayed on single store page and then using shortcode to add