/** * Output a pricing table * * * product_id/product_sku - id or sku of product. Defaults to current product, if any * * Usage: * [wc_measurement_price_calculator_pricing_table] * * @param array $atts associative array of shortcode parameters */ public static function output($atts) { global $product, $wpdb; extract(shortcode_atts(array('product_id' => '', 'product_sku' => ''), $atts)); // product by sku? if ($product_sku) { $product_id = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key='_sku' AND meta_value=%s LIMIT 1", $product_sku)); } // product by id? if ($product_id) { $product = wc_get_product($product_id); } // product ? if (!$product) { return; } // pricing rules? $settings = new WC_Price_Calculator_Settings($product); if (!$settings->pricing_rules_enabled() || !$settings->has_pricing_rules()) { return; } // the countdown element with a unique identifier to allow multiple countdowns on the same page, and common class for ease of styling echo self::get_pricing_rules_table($settings->get_pricing_rules($settings->get_pricing_unit()), $settings); }