本文整理汇总了PHP中WC_Product_Variation::get_formatted_name方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Product_Variation::get_formatted_name方法的具体用法?PHP WC_Product_Variation::get_formatted_name怎么用?PHP WC_Product_Variation::get_formatted_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WC_Product_Variation
的用法示例。
在下文中一共展示了WC_Product_Variation::get_formatted_name方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wpp_export
function wpp_export($export)
{
error_reporting(0);
ob_clean();
$export = addslashes(substr(strip_tags($_GET['wpp_export']), 0, 5));
@set_time_limit(864000);
if (ini_get('max_execution_time') != 864000) {
@ini_set('max_execution_time', 864000);
}
$post_id = url_to_postid($_SERVER['REQUEST_URI']);
$post = get_post($post_id);
if ($post->post_status != 'publish') {
return false;
}
if (post_password_required($post->ID)) {
return false;
}
$product = get_product($post->ID);
$out = '';
if (function_exists('has_post_thumbnail') && has_post_thumbnail($post->ID)) {
$thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'shop_single');
$wpp_featured_image = $thumbnail[0] ? $thumbnail[0] : $thumbnail[0];
} else {
$wpp_featured_image = '';
}
if ($thumbnail[1]) {
$wpp_featured_image = '<img width="' . $thumbnail[1] . '" height="' . $thumbnail[2] . '" src="' . $thumbnail[0] . '"/>';
}
$wpp_price_html = strip_tags($product->get_price_html());
$wpp_title = $post->post_title;
$wpp_sku = $product->get_sku();
$wpp_permalink = $product->get_permalink();
$wpp_stock = $product->get_stock_quantity();
$wpp_rating = strip_tags($product->get_rating_html());
$wpp_categories = $product->get_categories(', ');
$wpp_tags = $product->get_tags(', ');
$wpp_summary = wpp_text_filter($post->post_excerpt);
$wpp_description = wpp_text_filter($post->post_content);
$attribute_html = "\r\n<ul>";
if ($product->enable_dimensions_display()) {
$attribute_html .= $product->get_dimensions() ? '<li>' . get_option('wpp_ph_dimensions') . ': ' . $product->get_dimensions() . "\r\n</li>" : '';
}
$attribute_html .= $product->get_weight() ? '<li>' . get_option('wpp_ph_weight') . ': ' . $product->get_weight() . ' ' . get_option('woocommerce_weight_unit') . "\r\n</li>" : '';
if ($product->has_attributes()) {
$wpp_attributes = $product->get_attributes();
if (!empty($wpp_attributes)) {
foreach ($wpp_attributes as $attribute) {
if (!$attribute['is_visible']) {
continue;
}
if ($attribute['is_taxonomy']) {
$product_terms = wp_get_post_terms($post->ID, $attribute['name']);
$p_terms = array();
//$attribute_name = ucwords(str_replace('attribute_','',str_replace('pa_','',$attribute['name'])));
$attribute_name = wc_attribute_label($attribute['name']);
foreach ($product_terms as $p_term) {
$p_terms[] = $p_term->name;
}
$attribute_html .= '<li>' . $attribute_name . ': ' . implode(', ', $p_terms) . "\r\n</li>";
} else {
$attribute_html .= '<li>' . $attribute['name'] . ': ' . $attribute['value'] . "\r\n</li>";
}
}
}
}
$attribute_html .= '</ul>';
$attribute_html = str_replace(array(' |', '|'), ',', $attribute_html);
$wpp_has_variants = false;
$wpp_variants = "\r\n<ul>";
$args = array('post_type' => 'product_variation', 'post_status' => 'publish', 'numberposts' => -1, 'orderby' => 'menu_order', 'order' => 'asc', 'post_parent' => $post->ID);
$variations = get_posts($args);
if (!empty($variations)) {
$wpp_has_variants = true;
foreach ($variations as $variation) {
$vars = new WC_Product_Variation($variation->ID);
$wpp_variants .= '<li>' . str_replace($vars->get_sku(), '', html_entity_decode(strip_tags(wpp_text_filter(str_replace('–', ' - ', $vars->get_formatted_name()))), ENT_QUOTES, "UTF-8")) . "\r\n</li>";
unset($vars);
}
$wpp_variants .= '</ul>';
$wpp_variants = str_replace(array('<li> - ', ', - '), array('<li>', ' - '), $wpp_variants);
}
//Post Specific Custom Tabs
if ($product_meta = get_post_meta($post->ID)) {
foreach ($product_meta as $meta_key => $meta_value) {
if (strpos($meta_key, '_wpt_field_') !== FALSE) {
$custom_tab_slug = str_replace('_wpt_field_', '', $meta_key);
$custom_tab = get_posts(array('name' => $custom_tab_slug, 'posts_per_page' => 1, 'post_type' => 'woo_product_tab', 'post_status' => 'publish'));
if (trim($meta_value[0])) {
$custom_tab_title_html[] = $custom_tab[0]->post_title;
$custom_tab_content_html[] = wpp_text_filter($meta_value[0]);
}
}
continue;
}
}
//General Custom Tabs
$general_custom_tab = get_posts(array('posts_per_page' => -1, 'post_type' => 'woo_product_tab', 'post_status' => 'publish'));
foreach ($general_custom_tab as $tab) {
if (trim($tab->post_content)) {
$cfkey = '_wpt_field_' . $tab->post_name;
//.........这里部分代码省略.........