Add Custom Fields to Woo Variations

Sometimes each variation needs its own custom fields. Say if you need to add a unique UPC or EAN code. This turned out to be surprisingly simple. Thanks to Remi Corson for the code.

PS. You should check out Remi’s page for pretty much ANYTHING Woocommerce related. It is basically an infinite well of Woo knowledge.

Slick Carousel Basic Usage

Slick Carousel is pretty awesome. Not great in every instance but perfect for many. It is also very mobile friendly including swipe events.

Here is some basic setup code to get the slick slider working. This is being used in combination with Woocommerce thumbnails.

Now just initialize this slider somewhere.

 

Add Custom Value to Woocommerce Order

Woocommerce documentation, while thorough, can be hard to follow sometimes. Here are some functions I found somewhere on the Woocommerce site (which I can never find) that allows adding some custom values to the checkout order form and then attaching that value to the order.

 

 

Set Woocommerce State

Most clients want to limit the number of states they sell to…but for reasons beyond comprehension Woocommerce does not make this easy.

Here is some code to exclude a few state.

You  could also set the $states[‘US’] array to just the states you want if that would be easier.

Add Item to WooCommerce From Outside Shop

Sometimes I need to setup donations or memberships or some other item that needs to be added to a users cart but NOT be listed in the shop. First thing we should do is make sure to hide these items in the shop. For this to work you will need to set your Product Category. It can be anything you want of course. Then place this code in your functions.php file

Now that these items are hidden on the shop page (you may also find you need to hide them on other pages depending on your setup but just add those pages to the “if” check. Next we need to setup the code to add this to the cart.

Here is the basic code to add this to the cart. I have also setup a check to make sure no other items of the same category are in the cart, and if they are remove them and add this one. Then, if successful, direct the user to the cart page.

Get Product by SKU

Sometimes you need to find the page id of your product simply using the sku. I ran into this when I had to build a backend inventory manager which updated Receiving and Sales figures based off of some spreadsheets.

Stolen from: http://www.skyverge.com/blog/find-product-sku-woocommerce/

NOTE: The site I was working with was actually a Marketpress site and not a Woocommerce site. I ended up modifying the code from skyverge a little bit to fit my needs. Same idea.