add_shortcode('sku_stock_checker', 'my_sku_stock_checker_page'); function my_sku_stock_checker_page() { if (isset($_POST['sku_list'])) { $sku_list = array_filter(array_map('trim', explode("\n", $_POST['sku_list']))); $results = []; foreach ($sku_list as $sku) { $results = array_merge($results, get_stock_by_sku($sku)); } echo ""; foreach ($results as $row) { echo ""; } echo "
Title SKU Product Type Variation (Color) Stock Status Quantity
{$row['title']} {$row['sku']} {$row['type']} {$row['color']} {$row['status']} {$row['qty']}
"; } echo '


'; } function get_stock_by_sku($sku) { $rows = []; $product_id = wc_get_product_id_by_sku($sku); if (!$product_id) { $rows[] = ['title' => 'Not Found', 'sku' => $sku, 'type' => '-', 'color' => '-', 'status' => '-', 'qty' => '-']; return $rows; } $product = wc_get_product($product_id); // ✅ If SKU belongs to a variation if ($product->get_type() === 'variation') { $parent = wc_get_product($product->get_parent_id()); $color = get_variation_color($product); $rows[] = [ 'title' => $parent->get_title(), 'sku' => $sku, 'type' => 'Variable', 'color' => $color, 'status' => $product->get_stock_status(), 'qty' => $product->get_stock_quantity() ]; return $rows; } // ✅ If product is variable and parent SKU is entered if ($product->get_type() === 'variable') { foreach ($product->get_children() as $child_id) { $variation = wc_get_product($child_id); $color = get_variation_color($variation); $rows[] = [ 'title' => $product->get_title(), 'sku' => $variation->get_sku() ?: $sku, 'type' => 'Variable', 'color' => $color, 'status' => $variation->get_stock_status(), 'qty' => $variation->get_stock_quantity() ]; } return $rows; } // ✅ Simple Product $rows[] = [ 'title' => $product->get_title(), 'sku' => $sku, 'type' => 'Simple', 'color' => '-', 'status' => $product->get_stock_status(), 'qty' => $product->get_stock_quantity() ]; return $rows; } function get_variation_color($variation) { $attr = $variation->get_attributes(); foreach ($attr as $key => $value) { if (strpos($key, 'pa_color') !== false) { return ucwords(str_replace('-', ' ', $value)); } } return '-'; } Oxidised Chain Necklace With Jhumka Earrings - D9creation

Oxidised Chain Necklace With Jhumka Earrings

65.00

Out of stock

💰 Exclusive Discounts on Your Order Total:

  • ₹10,001 – 15,000 → 5% Discount
  • ₹15,001 – ₹20,000 → 7% Discount
  • Above ₹20,000 → 10% Discount
Discount will be automatically applied at checkout.

Brand : D9creation

Metal : German Silver

Chain : Pure Brass

Weight : 30 Gram

Visit Our Instagram Page
Placeholder
Oxidised Chain Necklace With Jhumka Earrings

Out of stock

Book Videocall Track Bulk Buy Review