本文整理汇总了PHP中WCJ_Module::create_meta_box方法的典型用法代码示例。如果您正苦于以下问题:PHP WCJ_Module::create_meta_box方法的具体用法?PHP WCJ_Module::create_meta_box怎么用?PHP WCJ_Module::create_meta_box使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WCJ_Module
的用法示例。
在下文中一共展示了WCJ_Module::create_meta_box方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
/**
* 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;
}
}
}
}
示例2:
/**
* 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);
}
}