Skip to content Skip to sidebar Skip to footer
Reading Time: 2 minutes

There are many functions available in WooCommerce that you can use to customize and enhance your online store. Here are some essential functions you should know.

1- Accessing functions using global $product object

Get product general info
global $product;



Get product prices
global $product;



Get Product Tax, Shipping & Stock
global $product;



Get Product Dimensions
global $product;



Get Linked Products
global $product;



Get Product Variations and Attributes
global $product;

$product->get_children(); // get variations
$product->get_attribute( 'attribute id here' ); //get specific attribute value


Get Product Taxonomies
global $product;



Get Product Downloads
global $product;



Get Product Images
global $product;



Get Product Reviews
global $product;



2- Accessing Core Functions

Product Functions
wc_get_product(): Get a product object by its ID.
wc_get_product_category_list(): Get the product's categories as a formatted string.
wc_get_product_tag_list(): Get the product's tags as a formatted string.
wc_product_gallery(): Display the product image gallery.
wc_get_product_reviews_rating_html(): Get the HTML for displaying the product reviews rating.


Cart Functions
WC()->cart->get_cart(): Get an array of products in the cart.
WC()->cart->add_to_cart(): Add a product to the cart.
WC()->cart->get_cart_contents_count(): Get the total number of items in the cart.
WC()->cart->get_cart_total(): Get the total cart amount. 


Checkout Functions
WC()->checkout->get_checkout_url(): Get the URL of the checkout page.
WC()->checkout->get_checkout_payment_url(): Get the URL of the payment page during the checkout process.
WC()->checkout->get_checkout_order_received_url(): Get the URL of the order received page after successful payment.


Order Functions
wc_create_order(): Create a new order programmatically.
wc_get_order(): Get an order object by its ID.
wc_get_orders(): Get an array of orders based on specific parameters.


User Account Functions
wc_get_customer_orders(): Get an array of customer orders.
wc_get_customer_average_spending(): Get the average spending of a customer.


Coupon Functions
wc_get_coupon_code() : Get the coupon code.
wc_get_coupon_amount() : Get the coupon amount.
wc_get_coupon_discount_type() : Get the coupon discount type.


General Functions
wc_price(): Format a price to the store's currency format.
wc_format_decimal(): Format a decimal number based on store settings.
wc_get_template_part(): Load WooCommerce template parts.
wc_enqueue_js(): Enqueue JavaScript scripts.
wc_enqueue_styles(): Enqueue stylesheets.