/** * Return an instance of this class. * * @return object A single instance of this class. */ public static function get_instance() { // If the single instance hasn't been set, set it now. if (null === self::$instance) { self::$instance = new self(); } return self::$instance; }
/** * Display the simulator. * * @return string Simulator HTML. */ public static function simulator() { global $product; if (!is_product()) { return; } if ('variable' == $product->product_type) { $style = 'display: none'; $ids = array(); foreach ($product->get_available_variations() as $variation) { $_variation = get_product($variation['variation_id']); $ids[] = $_variation->variation_id; } $ids = implode(',', array_filter($ids)); } else { $style = ''; $ids = $product->id; } if ($product->is_in_stock() && in_array($product->product_type, array('simple', 'variable'))) { wc_get_template('single-product/shipping-simulator.php', array('product' => $product, 'style' => $style, 'ids' => $ids), '', WC_Frenet_Main::get_templates_path()); } }