/** * create_meta_box. * * @version 2.4.5 * @since 2.4.5 * @todo min_profit */ function create_meta_box() { parent::create_meta_box(); // Report $main_product_id = get_the_ID(); $_product = wc_get_product($main_product_id); $products = array(); if ($_product->is_type('variable')) { $available_variations = $_product->get_available_variations(); foreach ($available_variations as $variation) { $variation_product = wc_get_product($variation['variation_id']); $products[$variation['variation_id']] = ' (' . $variation_product->get_formatted_variation_attributes(true) . ')'; } } else { $products[$main_product_id] = ''; } foreach ($products as $product_id => $desc) { $purchase_price = wc_get_product_purchase_price($product_id); if (0 != $purchase_price) { $the_product = wc_get_product($product_id); $the_price = $the_product->get_price(); if (0 != $the_price) { $the_profit = $the_price - $purchase_price; $table_data = array(); $table_data[] = array(__('Selling', 'woocommerce-jetpack'), wc_price($the_price)); $table_data[] = array(__('Buying', 'woocommerce-jetpack'), wc_price($purchase_price)); $table_data[] = array(__('Profit', 'woocommerce-jetpack'), wc_price($the_profit) . sprintf(' (%0.2f %%)', $the_profit / $purchase_price * 100)); // . sprintf( ' (%0.2f %%)', ( $the_profit / $the_price * 100 ) ) ); /* $the_min_profit = $purchase_price * 0.25; $the_min_price = $purchase_price * 1.25; $html .= __( 'Min Profit', 'woocommerce-jetpack' ); $html .= wc_price( $the_min_profit ) . ' ' . __( 'at', 'woocommerce-jetpack' ) . ' ' . wc_price( $the_min_price ); */ $html = ''; $html .= '<h5>' . __('Report', 'woocommerce-jetpack') . $desc . '</h5>'; $html .= wcj_get_table_html($table_data, array('table_heading_type' => 'none', 'table_class' => 'widefat striped', 'table_style' => 'width:50%;min-width:300px;', 'columns_styles' => array('width:33%;'))); echo $html; } } } }
/** * create_meta_box. * * @version 2.5.0 * @since 2.5.0 */ function create_meta_box() { parent::create_meta_box(); $the_product = wc_get_product(); if ($this->is_price_by_formula_product($the_product)) { $the_price = $the_product->get_price(); $the_price = $this->change_price_by_formula($the_price, $the_product, true); echo '<h4>' . __('Final Price Preview', 'woocommerce-jetpack') . '</h4>'; echo wc_price($the_price); } }