function display_shed_inventory($atts = array()) { $atts = shortcode_atts(array( 'feed_url' => 'https://superiorcustombarns.shedsuite.com/product_feed.xml', 'max_items' => 100, 'show_price' => 'true', 'show_description' => 'true' ), $atts); $store_locations = array( '4713' => array('name' => 'Superior Custom Barns', 'location' => 'Multiple Locations'), '4750' => array('name' => 'The Barnyard', 'location' => 'Pennsylvania'), '4751' => array('name' => '10K Barns', 'location' => 'Ohio'), '4767' => array('name' => 'Shed Movers Plus', 'location' => 'Pennsylvania'), '4768' => array('name' => 'Shed Movers Plus', 'location' => 'Pennsylvania'), '4769' => array('name' => 'Rosewood Outdoors LLC', 'location' => 'Pennsylvania'), '4770' => array('name' => 'Rosewood Outdoors LLC', 'location' => 'Pennsylvania'), '5825' => array('name' => 'East Point Custom Buildings', 'location' => 'Pennsylvania'), '5826' => array('name' => 'East Point Custom Buildings', 'location' => 'Pennsylvania') ); $output = '
'; $output .= '
'; $output .= '
'; $output .= '

FILTER

'; $output .= ''; $output .= ''; $output .= '
'; $output .= '
'; $output .= '
'; $output .= '

BUILDING TYPE

'; $output .= '
'; $building_types = array('Carriage House', 'Deluxe Metal Cabin', 'Deluxe Metal Lofted Barn', 'E Cabin', 'Economy Metal Garden Shed', 'Green House', 'Lofted Barn', 'Painted Cabin', 'Ranch House', 'Studio'); foreach ($building_types as $type) { $output .= '
'; } $output .= '
'; $output .= '
'; $output .= '

CONDITION

'; $output .= '
'; $output .= '
'; $output .= '
'; $output .= '
'; $output .= '
'; $output .= '

PRICE RANGE

'; $output .= '
'; $output .= ''; $output .= 'to'; $output .= ''; $output .= '
'; $output .= '
'; $output .= '

SIZE

'; $output .= '
'; $sizes = array('10x12', '10x16', '10x20', '12x16', '12x20', '12x24', '14x28', '14x32', '16x32', '16x40'); foreach ($sizes as $size) { $output .= '
'; } $output .= '
'; $output .= '
'; $output .= '
'; try { $response = wp_remote_get($atts['feed_url'], array('timeout' => 30, 'sslverify' => false)); if (is_wp_error($response)) { $output .= '
'; return $output; } $xml_content = wp_remote_retrieve_body($response); if (empty($xml_content)) { $output .= ''; return $output; } $xml = simplexml_load_string($xml_content); if ($xml === false) { $output .= ''; return $output; } $xml->registerXPathNamespace('g', 'http://base.google.com/ns/1.0'); $items = $xml->xpath('//item'); if (empty($items)) { $output .= ''; return $output; } $in_stock_count = 0; foreach ($items as $item) { $availability = (string)$item->xpath('.//g:availability')[0]; if (strtolower($availability) !== 'in stock') { continue; } if ($in_stock_count >= $atts['max_items']) { break; } $title = (string)$item->xpath('.//g:title')[0]; $price = (string)$item->xpath('.//g:price')[0]; $image_link = (string)$item->xpath('.//g:image_link')[0]; $condition = (string)$item->xpath('.//g:condition')[0]; $store_code = (string)$item->xpath('.//g:store_code')[0]; $formatted_price = ''; if ($price) { $price_parts = explode(' ', $price); $amount = number_format((float)$price_parts[0], 0); $formatted_price = '$' . $amount; } $product_details = $item->xpath('.//g:product_detail'); $roof_type = ''; $siding_type = ''; foreach ($product_details as $detail) { $section_name = (string)$detail->xpath('.//g:section_name')[0]; $attribute_value = (string)$detail->xpath('.//g:attribute_value')[0]; if (stripos($section_name, 'roof') !== false) { $roof_type = $attribute_value; } elseif (stripos($section_name, 'siding') !== false) { $siding_type = $attribute_value; } } $dealer_info = isset($store_locations[$store_code]) ? $store_locations[$store_code] : array('name' => 'Location Unknown', 'location' => ''); $output .= '
'; $output .= '
'; if ($image_link) { $output .= '' . esc_attr($title) . ''; } if ($condition) { $output .= '' . esc_html(strtoupper($condition)) . ''; } $output .= '
'; $output .= '
'; $output .= '
'; if ($formatted_price) { $output .= '
' . esc_html($formatted_price) . '
'; } if ($title) { $output .= '

' . esc_html($title) . '

'; } if ($roof_type || $siding_type) { $output .= '
'; if ($roof_type) { $output .= '
ROOF: ' . esc_html($roof_type) . '
'; } if ($siding_type) { $output .= '
SIDING: ' . esc_html($siding_type) . '
'; } $output .= '
'; } $output .= '
'; $output .= '
DEALER LOCATION
'; $output .= '
'; $output .= '
'; $output .= '
'; $output .= '
' . esc_html($dealer_info['name']) . '
'; if (!empty($dealer_info['location'])) { $output .= '
' . esc_html($dealer_info['location']) . '
'; } $output .= '
'; $output .= '
'; $in_stock_count++; } } catch (Exception $e) { $output .= '
Error loading inventory.
'; } $output .= ''; return $output; } add_shortcode('shed_inventory', 'display_shed_inventory'); https://sbarns.com/post-sitemap.xml 2024-03-21T15:13:50+00:00 https://sbarns.com/page-sitemap.xml 2025-06-12T15:52:46+00:00 https://sbarns.com/wpsl_stores-sitemap.xml 2024-12-09T16:22:48+00:00 https://sbarns.com/elementor-hf-sitemap.xml 2024-05-18T02:34:42+00:00 https://sbarns.com/category-sitemap.xml 2024-03-21T15:13:50+00:00 https://sbarns.com/post_tag-sitemap.xml 2024-03-21T15:13:50+00:00 https://sbarns.com/wpsl_store_category-sitemap.xml 2024-12-09T16:22:48+00:00 https://sbarns.com/author-sitemap.xml 2024-04-17T16:11:15+00:00