Skip to content

Instantly share code, notes, and snippets.

@stuart-lambon
stuart-lambon / woo-update-product-stock-qty.php
Created September 9, 2018 19:45
Updates WooCommerce product stock quantity programmatically. $sku and $qty variables need to be filled.
<?php
$sku = 'ITEM001';
$qty = 1;
// Get product_id from SKU — returns null if not found
$product_id = wc_get_product_id_by_sku( $sku );
// Process if product found
if ( $product_id != null ) {
@stuart-lambon
stuart-lambon / woo-return-to-shop-link.php
Created February 25, 2016 22:03
Change the WooCommerce ‘Return to shop’ link