php - how to get woocommerce product information outside loop in custom plugin -


How to obtain a product by ID outside the loop

This is my job:

  function rakhsh_product_info ($ id) {$ result = get_product ($ id); Die ($ result); }  

call get_product undefined function error

< P> Try it out:

  if (function_exists ('get_product')) {$ result = get_product ($ id); } And {$ result = new WC_Product ($ id); }  

Hope that helps.


Comments