WordPress Codesnippets

woocommerce get cart total

				
					
				
			

This code retrieves the total cost of all items in the WooCommerce cart. WC()->cart->get_cart_contents_total() is a function that computes the total cost of the items in the cart by adding the individual item costs together. The result is stored in the variable $cart_total.

Was this code snippet helpful?
YesNo

Leave a Reply

Your email address will not be published. Required fields are marked *

Programmatically save post

This code creates a WordPress post with the values of the ‘post_title’ and ‘post_content’ variables. It sets the post status to ‘publish’ and the author

Read More »

Create order programmatically

This code creates a new post in the WordPress database with post type ‘shop_order’, post title ‘Order #12345’, post status ‘wc-processing’, and ping status ‘closed’.

Read More »