当前位置: 首页>>代码示例>>PHP>>正文


PHP WC_Product::get_attributes方法代码示例

本文整理汇总了PHP中WC_Product::get_attributes方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Product::get_attributes方法的具体用法?PHP WC_Product::get_attributes怎么用?PHP WC_Product::get_attributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WC_Product的用法示例。


在下文中一共展示了WC_Product::get_attributes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: filter_custom_fields

 /**
  * Add woo attributes to a custom field with the same name
  *
  * @param $custom_fields
  * @param $post_id
  *
  * @return mixed
  */
 public function filter_custom_fields($custom_fields, $post_id)
 {
     if (!isset($custom_fields)) {
         $custom_fields = array();
     }
     // Get the product correponding to this post
     $product = new WC_Product($post_id);
     foreach ($product->get_attributes() as $attribute) {
         //$terms = wc_get_product_terms( $product->id, $attribute['name'], array( 'fields' => 'names' ) );
         // Remove the eventual 'pa_' prefix from the attribute name
         $attribute_name = $attribute['name'];
         if (substr($attribute_name, 0, 3) == 'pa_') {
             $attribute_name = substr($attribute_name, 3, strlen($attribute_name));
         }
         $custom_fields[$attribute_name] = explode(',', $product->get_attribute($attribute['name']));
     }
     return $custom_fields;
 }
开发者ID:zelle7,项目名称:wpsolr-search-engine,代码行数:26,代码来源:plugin-woocommerce.php

示例2: woocommerce_bulk_variations_create_matrix_v24

/** Modified Function - create matrix for row -- 03/02/2016 **/
function woocommerce_bulk_variations_create_matrix_v24($post_id)
{
    // 2.0 Compat
    if (function_exists('get_product')) {
        $_product = get_product($post_id);
    } else {
        $_product = new WC_Product($post_id);
    }
    $attributes = $_product->get_attributes();
    //Get first attribute -- 03/02/2016
    if (is_array($attributes) && count($attributes) > 0) {
        foreach ($attributes as $att) {
            $row_attribute = $att['name'];
            break;
        }
    }
    $av_temp = $_product->get_variation_attributes();
    $av = array();
    if (isset($attributes[$row_attribute]) && $attributes[$row_attribute]['is_taxonomy']) {
        $row_term_values = WC_Bulk_Variations_Compatibility::wc_get_product_terms($post_id, $row_attribute, 'all');
        foreach ($row_term_values as $row_term_value) {
            if (in_array($row_term_value->slug, $av_temp[$row_attribute])) {
                $av[$row_attribute][] = $row_term_value->slug;
            }
        }
    } else {
        $av[$row_attribute] = $av_temp[$row_attribute];
    }
    $grid = array();
    foreach ($av[$row_attribute] as $row_value) {
        $grid[$row_value] = null;
    }
    //Now sanitize the attributes, since $product->get_available_variations returns the variations sanitized, but get_variation_attributes does not
    $row_attribute = sanitize_title($row_attribute);
    $pv = $_product->get_available_variations();
    $filter = new WC_Bulk_Variation_Array_Filter('attribute_' . $row_attribute, $pv);
    foreach ($grid as $row_key => &$field_value) {
        $field_value = $filter->get_matches($row_key);
    }
    $matrix_data = array('row_attribute' => $row_attribute, 'matrix_rows' => array_values($av[$row_attribute]), 'matrix' => $grid);
    return $matrix_data;
}
开发者ID:jmagallanes,项目名称:cultura-woo-bulk-variations,代码行数:43,代码来源:woocommerce-bulk-variations-functions.php

示例3: save_variations_data

 /**
  * Save variations.
  *
  * @param WC_Product $product
  * @param WP_REST_Request $request
  * @return bool
  * @throws WC_REST_Exception
  */
 protected function save_variations_data($product, $request)
 {
     global $wpdb;
     $variations = $request['variations'];
     $attributes = $product->get_attributes();
     foreach ($variations as $menu_order => $variation) {
         $variation_id = isset($variation['id']) ? absint($variation['id']) : 0;
         // Generate a useful post title.
         $variation_post_title = sprintf(__('Variation #%s of %s', 'woocommerce'), $variation_id, esc_html(get_the_title($product->id)));
         // Update or Add post.
         if (!$variation_id) {
             $post_status = isset($variation['visible']) && false === $variation['visible'] ? 'private' : 'publish';
             $new_variation = array('post_title' => $variation_post_title, 'post_content' => '', 'post_status' => $post_status, 'post_author' => get_current_user_id(), 'post_parent' => $product->id, 'post_type' => 'product_variation', 'menu_order' => $menu_order);
             $variation_id = wp_insert_post($new_variation);
             do_action('woocommerce_create_product_variation', $variation_id);
         } else {
             $update_variation = array('post_title' => $variation_post_title, 'menu_order' => $menu_order);
             if (isset($variation['visible'])) {
                 $post_status = false === $variation['visible'] ? 'private' : 'publish';
                 $update_variation['post_status'] = $post_status;
             }
             $wpdb->update($wpdb->posts, $update_variation, array('ID' => $variation_id));
             do_action('woocommerce_update_product_variation', $variation_id);
         }
         // Stop with we don't have a variation ID.
         if (is_wp_error($variation_id)) {
             throw new WC_REST_Exception('woocommerce_rest_cannot_save_product_variation', $variation_id->get_error_message(), 400);
         }
         // SKU.
         if (isset($variation['sku'])) {
             $sku = get_post_meta($variation_id, '_sku', true);
             $new_sku = wc_clean($variation['sku']);
             if ('' === $new_sku) {
                 update_post_meta($variation_id, '_sku', '');
             } elseif ($new_sku !== $sku) {
                 if (!empty($new_sku)) {
                     $unique_sku = wc_product_has_unique_sku($variation_id, $new_sku);
                     if (!$unique_sku) {
                         throw new WC_REST_Exception('woocommerce_rest_product_sku_already_exists', __('The SKU already exists on another product.', 'woocommerce'), 400);
                     } else {
                         update_post_meta($variation_id, '_sku', $new_sku);
                     }
                 } else {
                     update_post_meta($variation_id, '_sku', '');
                 }
             }
         }
         // Thumbnail.
         if (isset($variation['image']) && is_array($variation['image'])) {
             $image = current($variation['image']);
             if ($image && is_array($image)) {
                 if (isset($image['position']) && 0 === $image['position']) {
                     $attachment_id = isset($image['id']) ? absint($image['id']) : 0;
                     if (0 === $attachment_id && isset($image['src'])) {
                         $upload = wc_rest_upload_image_from_url(wc_clean($image['src']));
                         if (is_wp_error($upload)) {
                             throw new WC_REST_Exception('woocommerce_product_image_upload_error', $upload->get_error_message(), 400);
                         }
                         $attachment_id = wc_rest_set_uploaded_image_as_attachment($upload, $product->id);
                     }
                     // Set the image alt if present.
                     if (!empty($image['alt'])) {
                         update_post_meta($attachment_id, '_wp_attachment_image_alt', wc_clean($image['alt']));
                     }
                     // Set the image name if present.
                     if (!empty($image['name'])) {
                         wp_update_post(array('ID' => $attachment_id, 'post_title' => $image['name']));
                     }
                     update_post_meta($variation_id, '_thumbnail_id', $attachment_id);
                 }
             } else {
                 delete_post_meta($variation_id, '_thumbnail_id');
             }
         }
         // Virtual variation.
         if (isset($variation['virtual'])) {
             $is_virtual = true === $variation['virtual'] ? 'yes' : 'no';
             update_post_meta($variation_id, '_virtual', $is_virtual);
         }
         // Downloadable variation.
         if (isset($variation['downloadable'])) {
             $is_downloadable = true === $variation['downloadable'] ? 'yes' : 'no';
             update_post_meta($variation_id, '_downloadable', $is_downloadable);
         } else {
             $is_downloadable = get_post_meta($variation_id, '_downloadable', true);
         }
         // Shipping data.
         $this->save_product_shipping_data($variation_id, $variation);
         // Stock handling.
         if (isset($variation['manage_stock'])) {
             $manage_stock = true === $variation['manage_stock'] ? 'yes' : 'no';
         } else {
//.........这里部分代码省略.........
开发者ID:pelmered,项目名称:woocommerce,代码行数:101,代码来源:class-wc-rest-products-controller.php

示例4: extract


//.........这里部分代码省略.........
     if ($data_grid_machine == 'internal') {
         $class_name = 'ts-image-link-grid-frame';
     } else {
         if ($data_grid_machine == 'freewall') {
             wp_enqueue_script('ts-extend-freewall');
             $class_name = 'ts-image-freewall-grid-frame';
         }
     }
     if (function_exists('vc_shortcode_custom_css_class')) {
         $css_class = apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $el_class . ' ' . $class_name . ' ' . vc_shortcode_custom_css_class($css, ' '), 'TS_VCSC_WooCommerce_ImageGrid_Basic', $atts);
     } else {
         $css_class = $class_name . ' ' . $el_class;
     }
     $fullwidth_allow = "true";
     $postCounter = 0;
     $modal_gallery = '';
     // Front-Edit Message
     if ($frontend_edit == "true") {
         $modal_gallery .= $grid_message;
         if ($loop->have_posts()) {
             while ($loop->have_posts()) {
                 $loop->the_post();
                 $matched_terms = 0;
                 $post_thumbnail = get_the_post_thumbnail();
                 if ($matched_terms == 0 && ($post_thumbnail != '' || $data_grid_invalid == "false")) {
                     $postCounter++;
                     if ($postCounter < $posts_limit + 1) {
                         $product_id = get_the_ID();
                         $product_title = get_the_title($product_id);
                         $post = get_post($product_id);
                         $product = new WC_Product($product_id);
                         $attachment_ids = $product->get_gallery_attachment_ids();
                         $product_sku = $product->get_sku();
                         $attributes = $product->get_attributes();
                         $stock = $product->is_in_stock() ? 'true' : 'false';
                         if ('' != $post_thumbnail) {
                             $grid_image = wp_get_attachment_image_src(get_post_thumbnail_id(), $content_images_size);
                             $modal_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full');
                             $grid_image = $grid_image[0];
                             $modal_image = $modal_image[0];
                         } else {
                             $grid_image = TS_VCSC_GetResourceURL('images/defaults/no_featured.png');
                             $modal_image = TS_VCSC_GetResourceURL('images/defaults/no_featured.png');
                         }
                         $categories = array();
                         if (taxonomy_exists($menu_tax)) {
                             foreach (get_the_terms($loop->post->ID, $menu_tax) as $term) {
                                 array_push($categories, $term->name);
                             }
                             $categories = implode($categories, ',');
                         }
                         $valid_images++;
                         $modal_gallery .= '<a style="' . $image_style . '" href="' . get_permalink() . '" target="_blank" title="' . get_the_title() . '">';
                         $modal_gallery .= '<img id="ts-image-link-picture-' . $randomizer . '-' . $i . '" class="ts-image-link-picture" src="' . $grid_image . '" rel="link-group-' . $randomizer . '" data-include="true" data-image="' . $modal_image . '" width="100%" height="auto" title="' . get_the_title() . '" data-groups="' . $categories . '" data-target="' . $data_grid_target . '" data-link="' . get_permalink() . '">';
                         $modal_gallery .= '</a>';
                         $categories = array();
                     }
                 }
             }
         } else {
             echo __("No products could be found.", "ts_visual_composer_extend");
         }
         wp_reset_postdata();
         wp_reset_query();
     } else {
         if ($loop->have_posts()) {
开发者ID:Telemedellin,项目名称:fonvalmed,代码行数:67,代码来源:ts_vcsc_woocommerce_custom_image.php

示例5: get_product_from_post


//.........这里部分代码省略.........
                 }
             }
         }
     } catch (Exception $e) {
     }
     $acf_fields = array();
     try {
         if (class_exists('acf') && function_exists('get_field')) {
             $all_acf_fields = get_option('wcis_acf_fields');
             if (is_array($all_acf_fields)) {
                 foreach ($all_acf_fields as $acf_field_name) {
                     $acf_field_value = get_field($acf_field_name, $post_id);
                     if ($acf_field_value) {
                         $acf_fields[$acf_field_name] = $acf_field_value;
                     }
                 }
             }
         }
     } catch (Exception $e) {
     }
     $send_product = array('product_id' => $product->id, 'currency' => get_woocommerce_currency(), 'price' => $product->get_price(), 'url' => get_permalink($product->id), 'thumbnail_url' => $thumbnail, 'action' => 'insert', 'description' => $product->get_post_data()->post_content, 'short_description' => $product->get_post_data()->post_excerpt, 'name' => $product->get_title(), 'sku' => $product->get_sku(), 'categories' => $product->get_categories(), 'tag' => $product_tags, 'store_id' => get_current_blog_id(), 'identifier' => (string) $product->id, 'product_brand' => $product_brands, 'taxonomies' => $taxonomies, 'acf_fields' => $acf_fields, 'sellable' => $product->is_purchasable(), 'visibility' => $product->is_visible(), 'stock_quantity' => $product->get_stock_quantity(), 'is_managing_stock' => $product->managing_stock(), 'is_backorders_allowed' => $product->backorders_allowed(), 'is_purchasable' => $product->is_purchasable(), 'is_in_stock' => $product->is_in_stock(), 'product_status' => get_post_status($post_id));
     try {
         $variable = new WC_Product_Variable($post_id);
         $variations = $variable->get_available_variations();
         $variations_sku = '';
         if (!empty($variations)) {
             foreach ($variations as $variation) {
                 if ($product->get_sku() != $variation['sku']) {
                     $variations_sku .= $variation['sku'] . ' ';
                 }
             }
         }
         $send_product['variations_sku'] = $variations_sku;
         $all_attributes = $product->get_attributes();
         $attributes = array();
         if (!empty($all_attributes)) {
             foreach ($all_attributes as $attr_mame => $value) {
                 if ($all_attributes[$attr_mame]['is_taxonomy']) {
                     if (!$woocommerce_ver_below_2_1) {
                         $attributes[$attr_mame] = wc_get_product_terms($post_id, $attr_mame, array('fields' => 'names'));
                     } else {
                         $attributes[$attr_mame] = woocommerce_get_product_terms($post_id, $attr_mame, 'names');
                     }
                 } else {
                     $attributes[$attr_mame] = $product->get_attribute($attr_mame);
                 }
             }
         }
         $send_product['attributes'] = $attributes;
         $send_product['total_variable_stock'] = $variable->get_total_stock();
         try {
             if (version_compare(WOOCOMMERCE_VERSION, '2.2', '>=')) {
                 if (function_exists('wc_get_product')) {
                     $original_product = wc_get_product($product->id);
                     if (is_object($original_product)) {
                         $send_product['visibility'] = $original_product->is_visible();
                         $send_product['product_type'] = $original_product->product_type;
                     }
                 }
             } else {
                 if (function_exists('get_product')) {
                     $original_product = get_product($product->id);
                     if (is_object($original_product)) {
                         $send_product['visibility'] = $original_product->is_visible();
                         $send_product['product_type'] = $original_product->product_type;
                     }
开发者ID:booklein,项目名称:wpbookle,代码行数:67,代码来源:wcis_plugin.php

示例6: wpmp_content_invoice

 public function wpmp_content_invoice($order, $order_detail_by_order_id)
 {
     $msg = '<!-- Content -->';
     $msg .= '<table border="0" cellpadding="20" cellspacing="0" width="100%">';
     $msg .= '<tr>';
     $msg .= '<td valign="top" style="padding: 48px;">';
     $msg .= '<div id="body_content_inner" style="color: #737373;  font-size: 14px; line-height: 150%; text-align: left;"">';
     $msg .= '<p style="margin: 0 0 16px;">You have received an order from ' . $order->billing_first_name . ' ' . $order->billing_last_name . '. The order is as follows:</p>';
     $msg .= '<h2 style="color: #557da1; display: block; font-size: 18px; font-weight: bold; line-height: 130%; margin: 16px 0 8px; text-align: left;"">';
     $msg .= 'Order #' . $order->id . ' ( ' . date_i18n(wc_date_format(), strtotime($order->order_date)) . ' )';
     $msg .= '</h2>';
     $msg .= '<table cellspacing="0" cellpadding="6" style="width: 100%; border: 1px solid #eee;" border="1" bordercolor="#eee">';
     $msg .= '<thead>';
     $msg .= '<tr>';
     $msg .= '<th scope="col" style="text-align: left; border: 1px solid #eee; padding: 12px;">Product</th>';
     $msg .= '<th scope="col" style="text-align: left; border: 1px solid #eee; padding: 12px;">Quantity</th>';
     $msg .= '<th scope="col" style="text-align: left; border: 1px solid #eee; padding: 12px;">Price</th>';
     $msg .= '</tr>';
     $msg .= '</thead>';
     $msg .= '<tbody>';
     $total_payment = 0;
     $cur_symbol = get_woocommerce_currency_symbol(get_option('woocommerce_currency'));
     foreach ($order_detail_by_order_id as $product_id => $details) {
         for ($i = 0; $i < count($details); $i++) {
             $total_payment = $total_payment + intval($details[$i]['product_total_price']);
             if ($details[$i]['variable_id'] == 0) {
                 $msg .= '<tr>';
                 $msg .= '<td style="text-align: left; vertical-align: middle; border: 1px solid #eee; word-wrap: break-word; padding: 12px;">' . $details[$i]['product_name'];
                 $msg .= '<br>';
                 $msg .= '<small></small>';
                 $msg .= '</td>';
                 $msg .= '<td style="text-align: left; vertical-align: middle; border: 1px solid #eee; padding: 12px;">' . $details[$i]['qty'] . '</td>';
                 $msg .= '<td style="text-align: left; vertical-align: middle; border: 1px solid #eee; padding: 12px;">';
                 $msg .= '<span class="amount">' . $cur_symbol . $details[$i]['product_total_price'] . '</span>';
                 $msg .= '</td>';
                 $msg .= '</tr>';
             } else {
                 $product = new WC_Product($product_id);
                 $attribute = $product->get_attributes();
                 $attribute_name = '';
                 foreach ($attribute as $key => $value) {
                     $attribute_name = $value['name'];
                 }
                 $variation = new WC_Product_Variation($details[$i]['variable_id']);
                 $aaa = $variation->get_variation_attributes();
                 $attribute_prop = strtoupper($aaa['attribute_' . strtolower($attribute_name)]);
                 $msg .= '<tr>';
                 $msg .= '<td style="text-align: left; vertical-align: middle; border: 1px solid #eee; word-wrap: break-word; padding: 12px;">' . $details[$i]['product_name'];
                 $msg .= '<br><small>' . $attribute_name . ':' . $attribute_prop . '</small>';
                 $msg .= '</td>';
                 $msg .= '<td style="text-align: left; vertical-align: middle; border: 1px solid #eee; padding: 12px;">' . $details[$i]['qty'] . '</td>';
                 $msg .= '<td style="text-align: left; vertical-align: middle; border: 1px solid #eee; padding: 12px;">';
                 $msg .= '<span class="amount">' . $cur_symbol . $details[$i]['product_total_price'] . '</span>';
                 $msg .= '</td>';
                 $msg .= '</tr>';
             }
         }
     }
     $msg .= '</tbody>';
     $msg .= '<tfoot>';
     /*$msg .= '<!--  <tr>';
           $msg .= '<th scope="row" colspan="2" style="text-align: left; border: 1px solid #eee; border-top-width: 4px; padding: 12px;">Subtotal:</th>';
           $msg .= '<td style="text-align: left; border: 1px solid #eee; border-top-width: 4px; padding: 12px;">';
               $msg .= '<span class="amount"></span>';
           $msg .= '</td>';
       $msg .= '</tr> -->';*/
     $msg .= '<tr>';
     $msg .= '<th scope="row" colspan="2" style="text-align: left; border: 1px solid #eee; padding: 12px;">Shipping:</th>';
     $msg .= '<td style="text-align: left; border: 1px solid #eee; padding: 12px;">' . $order->get_shipping_method() . '</td>';
     $msg .= '</tr>';
     $msg .= '<tr>';
     $msg .= '<th scope="row" colspan="2" style="text-align: left; border: 1px solid #eee; padding: 12px;">Payment Method:</th>';
     $msg .= '<td style="text-align: left; border: 1px solid #eee; padding: 12px;">' . $order->payment_method_title . '</td>';
     $msg .= '</tr>';
     $msg .= '<tr>';
     $msg .= '<th scope="row" colspan="2" style="text-align: left; border: 1px solid #eee; padding: 12px;">Total:</th>';
     $msg .= '<td style="text-align: left; border: 1px solid #eee; padding: 12px;">';
     $msg .= '<span class="amount">' . $total_payment . '</span>';
     $msg .= '</td>';
     $msg .= '</tr>';
     $msg .= '</tfoot>';
     $msg .= '</table>';
     $msg .= '<h2 style="color: #557da1; display: block; font-size: 18px; font-weight: bold; line-height: 130%; margin: 16px 0 8px; text-align: left;">Customer details</h2>';
     $msg .= '<p style="margin: 0 0 16px;">';
     $msg .= '<strong>Email:</strong>';
     if ($order->billing_email) {
         $msg .= $order->billing_email;
     }
     $msg .= '</p>';
     $msg .= '<p style="margin: 0 0 16px;">';
     $msg .= '<strong>Tel:</strong>';
     if ($order->billing_phone) {
         $msg .= $order->billing_phone;
     }
     $msg .= '</p>';
     $msg .= '<table cellspacing="0" cellpadding="0" style="width: 100%; vertical-align: top;" border="0">';
     $msg .= '<tr>';
     $msg .= '<td valign="top" width="50%" style="padding: 12px;">';
     $font = ' font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif;';
     $msg .= "<h3 style='color: #557da1; display: block;" . $font . " font-size: 16px; font-weight: bold; line-height: 130%; margin: 16px 0 8px; text-align: left;'>Billing address</h3>";
//.........这里部分代码省略.........
开发者ID:pcuervo,项目名称:mobbily-wordpress,代码行数:101,代码来源:class-mp-form-handler.php

示例7: woocommerce_link_all_variations

function woocommerce_link_all_variations()
{
    check_ajax_referer('link-variations', 'security');
    @set_time_limit(0);
    $post_id = intval($_POST['post_id']);
    if (!$post_id) {
        die;
    }
    $variations = array();
    $_product = new WC_Product($post_id);
    // Put variation attributes into an array
    foreach ($_product->get_attributes() as $attribute) {
        if (!$attribute['is_variation']) {
            continue;
        }
        $attribute_field_name = 'attribute_' . sanitize_title($attribute['name']);
        if ($attribute['is_taxonomy']) {
            $post_terms = wp_get_post_terms($post_id, $attribute['name']);
            $options = array();
            foreach ($post_terms as $term) {
                $options[] = $term->slug;
            }
        } else {
            $options = explode('|', $attribute['value']);
        }
        $options = array_map('trim', $options);
        $variations[$attribute_field_name] = $options;
    }
    // Quit out if none were found
    if (sizeof($variations) == 0) {
        die;
    }
    // Get existing variations so we don't create duplicated
    $available_variations = array();
    foreach ($_product->get_children() as $child_id) {
        $child = $_product->get_child($child_id);
        if ($child instanceof WC_Product_Variation) {
            $available_variations[] = $child->get_variation_attributes();
        }
    }
    // Created posts will all have the following data
    $variation_post_data = array('post_title' => 'Product #' . $post_id . ' Variation', 'post_content' => '', 'post_status' => 'publish', 'post_author' => get_current_user_id(), 'post_parent' => $post_id, 'post_type' => 'product_variation');
    // Now find all combinations and create posts
    if (!function_exists('array_cartesian')) {
        function array_cartesian($input)
        {
            $result = array();
            while (list($key, $values) = each($input)) {
                // If a sub-array is empty, it doesn't affect the cartesian product
                if (empty($values)) {
                    continue;
                }
                // Special case: seeding the product array with the values from the first sub-array
                if (empty($result)) {
                    foreach ($values as $value) {
                        $result[] = array($key => $value);
                    }
                } else {
                    // Second and subsequent input sub-arrays work like this:
                    //   1. In each existing array inside $product, add an item with
                    //      key == $key and value == first item in input sub-array
                    //   2. Then, for each remaining item in current input sub-array,
                    //      add a copy of each existing array inside $product with
                    //      key == $key and value == first item in current input sub-array
                    // Store all items to be added to $product here; adding them on the spot
                    // inside the foreach will result in an infinite loop
                    $append = array();
                    foreach ($result as &$product) {
                        // Do step 1 above. array_shift is not the most efficient, but it
                        // allows us to iterate over the rest of the items with a simple
                        // foreach, making the code short and familiar.
                        $product[$key] = array_shift($values);
                        // $product is by reference (that's why the key we added above
                        // will appear in the end result), so make a copy of it here
                        $copy = $product;
                        // Do step 2 above.
                        foreach ($values as $item) {
                            $copy[$key] = $item;
                            $append[] = $copy;
                        }
                        // Undo the side effecst of array_shift
                        array_unshift($values, $product[$key]);
                    }
                    // Out of the foreach, we can add to $results now
                    $result = array_merge($result, $append);
                }
            }
            return $result;
        }
    }
    $variation_ids = array();
    $added = 0;
    $possible_variations = array_cartesian($variations);
    foreach ($possible_variations as $variation) {
        // Check if variation already exists
        if (in_array($variation, $available_variations)) {
            continue;
        }
        $variation_id = wp_insert_post($variation_post_data);
        $variation_ids[] = $variation_id;
//.........这里部分代码省略.........
开发者ID:bidhanbaral,项目名称:fotodep_store,代码行数:101,代码来源:woocommerce-ajax.php

示例8: find_matching_product_variation

 /**
  * Find a matching (enabled) variation within a variable product.
  *
  * @since  2.7.0
  * @param  WC_Product $product Variable product.
  * @param  array $match_attributes Array of attributes we want to try to match.
  * @return int Matching variation ID or 0.
  */
 public function find_matching_product_variation($product, $match_attributes = array())
 {
     $query_args = array('post_parent' => $product->get_id(), 'post_type' => 'product_variation', 'orderby' => 'menu_order', 'order' => 'ASC', 'fields' => 'ids', 'post_status' => 'publish', 'numberposts' => 1, 'meta_query' => array());
     // Allow large queries in case user has many variations or attributes.
     $GLOBALS['wpdb']->query('SET SESSION SQL_BIG_SELECTS=1');
     foreach ($product->get_attributes() as $attribute) {
         if (!$attribute->get_variation()) {
             continue;
         }
         $attribute_field_name = 'attribute_' . sanitize_title($attribute->get_name());
         if (!isset($match_attributes[$attribute_field_name])) {
             return 0;
         }
         $value = wc_clean($match_attributes[$attribute_field_name]);
         $query_args['meta_query'][] = array('relation' => 'OR', array('key' => $attribute_field_name, 'value' => array('', $value), 'compare' => 'IN'), array('key' => $attribute_field_name, 'compare' => 'NOT EXISTS'));
     }
     $variations = get_posts($query_args);
     if ($variations && !is_wp_error($variations)) {
         return current($variations);
     } elseif (version_compare(get_post_meta($product->get_id(), '_product_version', true), '2.4.0', '<')) {
         /**
          * Pre 2.4 handling where 'slugs' were saved instead of the full text attribute.
          * Fallback is here because there are cases where data will be 'synced' but the product version will remain the same.
          */
         return array_map('sanitize_title', $match_attributes) === $match_attributes ? 0 : $this->find_matching_product_variation($product, array_map('sanitize_title', $match_attributes));
     }
     return 0;
 }
开发者ID:shivapoudel,项目名称:woocommerce,代码行数:36,代码来源:class-wc-product-data-store-cpt.php

示例9: array


//.........这里部分代码省略.........
                 echo '<div>' . __("Sort Criterion", "ts_visual_composer_extend") . ': ' . $value . '</div>';
             }
         }
         $front_edit_reverse = array("asc" => __('Bottom to Top', "ts_visual_composer_extend"), "desc" => __('Top to Bottom', "ts_visual_composer_extend"));
         foreach ($front_edit_reverse as $key => $value) {
             if ($key == $sort_order) {
                 echo '<div>' . __("Initial Order", "ts_visual_composer_extend") . ': ' . $value . '</div>';
             }
         }
         echo '<div>' . __("Show Filter Button", "ts_visual_composer_extend") . ': ' . $filter_menu . '</div>';
         echo '<div>' . __("Show Layout Button", "ts_visual_composer_extend") . ': ' . $layout_menu . '</div>';
         echo '<div>' . __("Show Sort Criterion Button", "ts_visual_composer_extend") . ': ' . $sort_menu . '</div>';
         echo '<div>' . __("Show Directions Buttons", "ts_visual_composer_extend") . ': ' . $directions_menu . '</div>';
         echo '</div>';
     } else {
         $opening .= '<div id="' . $posts_container_id . '" class="ts-isotope-posts-grid-parent ' . ($layout == 'spineTimeline' ? 'ts-timeline ' : 'ts-postsgrid ') . 'ts-timeline-' . $sort_order . ' ts-posts-timeline ' . $isotope_posts_list_class . ' ' . $css_class . '" style="margin-top: ' . $margin_top . 'px; margin-bottom: ' . $margin_bottom . ';" data-lazy="' . $posts_lazy . '" data-count="' . $posts_limit . '" data-ajax="' . $posts_ajax . '" data-trigger="' . $posts_trigger . '" data-column="' . $column_width . '" data-layout="' . $layout . '" data-sort="' . $sort_by . '" data-order="' . $sort_order . '" data-break="' . $layout_break . '" data-type="' . $post_type . '">';
         // Create Individual Post Output
         $postCounter = 0;
         $postCategories = array();
         $categoriesCount = 0;
         if (post_type_exists($post_type) && $loop->have_posts()) {
             $products .= '<div class="ts-timeline-content">';
             $products .= '<ul id="ts-isotope-posts-grid-' . $postsgrid_random . '" class="ts-isotope-posts-grid ts-timeline-list" data-layout="' . $layout . '" data-key="' . $postsgrid_random . '">';
             while ($loop->have_posts()) {
                 $loop->the_post();
                 $postCounter++;
                 $product_id = get_the_ID();
                 $product_title = get_the_title($product_id);
                 $post = get_post($product_id);
                 $product = new WC_Product($product_id);
                 $attachment_ids = $product->get_gallery_attachment_ids();
                 $price = $product->get_price_html();
                 $product_sku = $product->get_sku();
                 $attributes = $product->get_attributes();
                 $stock = $product->is_in_stock() ? 'true' : 'false';
                 $onsale = $product->is_on_sale() ? 'true' : 'false';
                 // Rating Settings
                 $rating_html = $product->get_rating_html();
                 $rating = $product->get_average_rating();
                 if ($rating == '') {
                     $rating = 0;
                 }
                 if ($rating_quarter == "true") {
                     $rating_value = floor($rating * 4) / 4;
                 } else {
                     $rating_value = $rating;
                 }
                 $rating_value = number_format($rating_value, 2, $caption_digits, '');
                 if ($rating_rtl == "false") {
                     $rating_width = $rating_value / $rating_maximum * 100;
                 } else {
                     $rating_width = 100 - $rating_value / $rating_maximum * 100;
                 }
                 if ($rating_symbol == "other") {
                     if ($rating_icon == "ts-ecommerce-starfull1") {
                         $rating_class = 'ts-rating-stars-star1';
                     } else {
                         if ($rating_icon == "ts-ecommerce-starfull2") {
                             $rating_class = 'ts-rating-stars-star2';
                         } else {
                             if ($rating_icon == "ts-ecommerce-starfull3") {
                                 $rating_class = 'ts-rating-stars-star3';
                             } else {
                                 if ($rating_icon == "ts-ecommerce-starfull4") {
                                     $rating_class = 'ts-rating-stars-star4';
                                 } else {
开发者ID:ryansm,项目名称:saud,代码行数:67,代码来源:ts_vcsc_woocommerce_custom_grid.php

示例10: extract


//.........这里部分代码省略.........
						data-next="ts-newsticker-controls-next-' . $woo_random . '"
						data-prev="ts-newsticker-controls-prev-' . $woo_random . '"
						data-play="ts-newsticker-controls-play-' . $woo_random . '"
						data-stop="ts-newsticker-controls-stop-' . $woo_random . '">';
                $output .= '<div class="ts-newsticker-elements-frame ' . $newsticker_elements . ' ' . $ticker_border_radius . '" style="">';
                // Add Navigation Controls
                $output .= '<div id="ts-newsticker-controls-' . $woo_random . '" class="ts-newsticker-controls" style="' . ($ticker_controls == "true" ? "display: block;" : "display: none;") . ' ' . $newsticker_controls . '">';
                $output .= '<div id="ts-newsticker-controls-next-' . $woo_random . '" style="' . ($ticker_controls == "true" ? "display: block;" : "display: none;") . '" class="ts-newsticker-controls-next"><span class="ts-ecommerce-arrowright5"></span></div>';
                $output .= '<div id="ts-newsticker-controls-prev-' . $woo_random . '" style="' . ($ticker_controls == "true" ? "display: block;" : "display: none;") . '" class="ts-newsticker-controls-prev"><span class="ts-ecommerce-arrowleft5"></span></div>';
                $output .= '<div id="ts-newsticker-controls-stop-' . $woo_random . '" class="ts-newsticker-controls-play" style="' . ($ticker_auto == "true" ? "display: block;" : "display: none;") . '"><span class="ts-ecommerce-pause"></span></div>';
                $output .= '<div id="ts-newsticker-controls-play-' . $woo_random . '" class="ts-newsticker-controls-play" style="' . ($ticker_auto == "true" ? "display: none;" : "display: block;") . '"><span class="ts-ecommerce-play"></span></div>';
                $output .= '</div>';
                if ($ticker_side == "left" && $ticker_title == "true") {
                    $output .= '<div id="ts-newsticker-header-' . $woo_random . '" class="header ' . $ticker_border_radius . '" style="background: ' . $ticker_background . '; color: ' . $ticker_color . '; left: 0;">';
                    if ($ticker_icon != '' && $ticker_icon != 'transparent' && $ticker_symbol == "true") {
                        $output .= '<i class="ts-font-icon ' . $ticker_icon . '" style="color: ' . $ticker_paint . '"></i>';
                    }
                    $output .= '<span>' . $ticker_header . '</span>';
                    $output .= '</div>';
                }
                $output .= '<ul id="ts-newsticker-ticker-' . $woo_random . '" class="newsticker ' . $ticker_border_radius . '" style="' . $newsticker_header . '">';
                while ($loop->have_posts()) {
                    $loop->the_post();
                    $postCounter++;
                    if ($postCounter < $posts_limit + 1) {
                        $postAttributes = 'data-full="' . get_post_time($date_format) . '" data-time="' . get_post_time($time_format) . '" data-author="' . get_the_author() . '" data-date="' . get_post_time('U') . '" data-modified="' . get_the_modified_time('U') . '" data-title="' . get_the_title() . '" data-comments="' . get_comments_number() . '" data-id="' . get_the_ID() . '"';
                        $product_id = get_the_ID();
                        $product_title = get_the_title($product_id);
                        $post = get_post($product_id);
                        $product = new WC_Product($product_id);
                        $attachment_ids = $product->get_gallery_attachment_ids();
                        $price = $product->get_price_html();
                        $product_sku = $product->get_sku();
                        $attributes = $product->get_attributes();
                        $stock = $product->is_in_stock() ? 'true' : 'false';
                        $onsale = $product->is_on_sale() ? 'true' : 'false';
                        // Rating Settings
                        $rating_html = $product->get_rating_html();
                        $rating = $product->get_average_rating();
                        if ($rating == '') {
                            $rating = 0;
                        }
                        if ($rating_quarter == "true") {
                            $rating_value = floor($rating * 4) / 4;
                        } else {
                            $rating_value = $rating;
                        }
                        $rating_value = number_format($rating_value, 2, $caption_digits, '');
                        if ($rating_rtl == "false") {
                            $rating_width = $rating_value / $rating_maximum * 100;
                        } else {
                            $rating_width = 100 - $rating_value / $rating_maximum * 100;
                        }
                        if ($rating_symbol == "other") {
                            if ($rating_icon == "ts-ecommerce-starfull1") {
                                $rating_class = 'ts-rating-stars-star1';
                            } else {
                                if ($rating_icon == "ts-ecommerce-starfull2") {
                                    $rating_class = 'ts-rating-stars-star2';
                                } else {
                                    if ($rating_icon == "ts-ecommerce-starfull3") {
                                        $rating_class = 'ts-rating-stars-star3';
                                    } else {
                                        if ($rating_icon == "ts-ecommerce-starfull4") {
                                            $rating_class = 'ts-rating-stars-star4';
                                        } else {
开发者ID:baochung26,项目名称:happy-c,代码行数:67,代码来源:ts_vcsc_woocommerce_custom_ticker.php

示例11: add_product

 /**
  * Add a product line item to the order. This is the only line item type with
  * it's own method because it saves looking up order amounts (costs are added up for you).
  * @param  \WC_Product $product
  * @param  int $qty
  * @param  array $args
  * @return int order item ID
  * @throws WC_Data_Exception
  */
 public function add_product($product, $qty = 1, $args = array())
 {
     if ($product) {
         $default_args = array('name' => $product->get_name(), 'tax_class' => $product->get_tax_class(), 'product_id' => $product->is_type('variation') ? $product->get_parent_id() : $product->get_id(), 'variation_id' => $product->is_type('variation') ? $product->get_id() : 0, 'variation' => $product->is_type('variation') ? $product->get_attributes() : array(), 'subtotal' => wc_get_price_excluding_tax($product, array('qty' => $qty)), 'total' => wc_get_price_excluding_tax($product, array('qty' => $qty)), 'quantity' => $qty);
     } else {
         $default_args = array('quantity' => $qty);
     }
     $args = wp_parse_args($args, $default_args);
     // BW compatibility with old args
     if (isset($args['totals'])) {
         foreach ($args['totals'] as $key => $value) {
             if ('tax' === $key) {
                 $args['total_tax'] = $value;
             } elseif ('tax_data' === $key) {
                 $args['taxes'] = $value;
             } else {
                 $args[$key] = $value;
             }
         }
     }
     $item = new WC_Order_Item_Product();
     $item->set_props($args);
     $item->set_backorder_meta();
     $item->set_order_id($this->get_id());
     $item->save();
     $this->add_item($item);
     wc_do_deprecated_action('woocommerce_order_add_product', array($this->get_id(), $item->get_id(), $product, $qty, $args), '2.7', 'Use woocommerce_new_order_item action instead.');
     return $item->get_id();
 }
开发者ID:woocommerce,项目名称:woocommerce,代码行数:38,代码来源:abstract-wc-order.php

示例12: get_tour_details_attributes

 /**
  * Returns modified tour attributes where each element contains information about attribute label,
  * value and icon class.
  *
  * @param  WC_Product  $product               product for that attributes should be retrived.
  * @param  boolean     $onlyAllowedInSettings if attributes should be filtered with values allowed in theme options.
  * @return array
  */
 public static function get_tour_details_attributes($product, $onlyAllowedInSettings = true)
 {
     $result = array();
     $list = $product->get_attributes();
     $allowedList = adventure_tours_get_option('tours_page_top_attributes');
     if (!$list || $onlyAllowedInSettings && !$allowedList) {
         return $result;
     }
     foreach ($list as $name => $attribute) {
         $attrib_name = $attribute['name'];
         if (empty($attribute['is_visible']) || $attribute['is_taxonomy'] && !taxonomy_exists($attrib_name)) {
             continue;
         }
         if (false === $onlyAllowedInSettings && in_array($attrib_name, $allowedList)) {
             continue;
         }
         if ($attribute['is_taxonomy']) {
             $values = wc_get_product_terms($product->id, $attrib_name, array('fields' => 'names'));
             $text = apply_filters('woocommerce_attribute', wptexturize(implode(', ', $values)), $attribute, $values);
         } else {
             // Convert pipes to commas and display values
             $values = array_map('trim', explode(WC_DELIMITER, $attribute['value']));
             $text = apply_filters('woocommerce_attribute', wptexturize(implode(', ', $values)), $attribute, $values);
         }
         $result[$attrib_name] = array('name' => $attrib_name, 'label' => wc_attribute_label($attrib_name), 'values' => $values, 'text' => $text, 'icon_class' => self::get_product_attribute_icon_class($attribute));
     }
     // We need reorder items according order in settings.
     if ($onlyAllowedInSettings && $result) {
         $orderedList = array();
         foreach ($allowedList as $attribKey) {
             if (!empty($result[$attribKey])) {
                 $orderedList[$attribKey] = $result[$attribKey];
             }
         }
         return $orderedList;
     }
     return $result;
 }
开发者ID:j-kenneth,项目名称:Expeero,代码行数:46,代码来源:AtTourHelper.php

示例13: extract

 function TS_VCSC_WooCommerce_Rating_Basic_Function($atts, $content = null)
 {
     global $VISUAL_COMPOSER_EXTENSIONS;
     global $product;
     global $woocommerce;
     ob_start();
     if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_LoadFrontEndForcable == "false") {
         wp_enqueue_style('ts-extend-simptip');
         wp_enqueue_style('ts-font-ecommerce');
         wp_enqueue_style('ts-visual-composer-extend-front');
         wp_enqueue_script('ts-visual-composer-extend-front');
     }
     extract(shortcode_atts(array('best_rated' => 'false', 'id' => '', 'rating_maximum' => 5, 'rating_size' => 24, 'rating_quarter' => 'true', 'rating_title' => 'true', 'rating_auto' => 'true', 'rating_position' => 'top', 'rating_rtl' => 'false', 'rating_symbol' => 'other', 'rating_icon' => '', 'color_rated' => '#FFD800', 'color_empty' => '#e3e3e3', 'caption_show' => 'true', 'caption_position' => 'left', 'caption_digits' => '.', 'caption_danger' => '#d9534f', 'caption_warning' => '#f0ad4e', 'caption_info' => '#5bc0de', 'caption_primary' => '#428bca', 'caption_success' => '#5cb85c', 'title_size' => 24, 'title_truncate' => 'true', 'use_name' => 'true', 'custom_title' => '', 'show_cart' => 'true', 'cart_color' => '#cccccc', 'show_link' => 'true', 'link_color' => '#cccccc', 'tooltip_css' => 'false', 'tooltip_content' => '', 'tooltip_position' => 'ts-simptip-position-top', 'tooltip_style' => '', 'margin_top' => 20, 'margin_bottom' => 20, 'el_id' => '', 'el_class' => '', 'css' => ''), $atts));
     // Final Query Arguments
     add_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses'));
     $meta_query = WC()->query->get_meta_query();
     $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => -1, 'orderby' => 'date', 'order' => 'desc', 'paged' => 1, 'meta_query' => $meta_query);
     $loop = new WP_Query($args);
     if ($loop->have_posts()) {
         $best_rating = 0;
         while ($loop->have_posts()) {
             $loop->the_post();
             $product_id = get_the_ID();
             $product = new WC_Product($product_id);
             if ($product_id == $id) {
                 $product_title = get_the_title($product_id);
                 $post = get_post($product_id);
                 $product = new WC_Product($product_id);
                 $attachment_ids = $product->get_gallery_attachment_ids();
                 $price = $product->get_price_html();
                 $product_sku = $product->get_sku();
                 $attributes = $product->get_attributes();
                 $stock = $product->is_in_stock() ? 'true' : 'false';
                 $onsale = $product->is_on_sale() ? 'true' : 'false';
                 $link = get_permalink();
                 // Rating Settings
                 $rating_html = $product->get_rating_html();
                 $rating = $product->get_average_rating();
                 if ($rating == '') {
                     $rating = 0;
                 }
                 if ($rating_quarter == "true") {
                     $rating_value = floor($rating * 4) / 4;
                 } else {
                     $rating_value = $rating;
                 }
                 $rating_value = number_format($rating_value, 2, $caption_digits, '');
                 break;
             }
         }
     }
     wp_reset_postdata();
     wp_reset_query();
     if ($rating_title == "true") {
         if ($use_name == "true") {
             $rating_title = $product_title;
         } else {
             $rating_title = $custom_title;
         }
     } else {
         $rating_title = '';
     }
     if ($rating_rtl == "false") {
         $rating_width = $rating_value / $rating_maximum * 100;
     } else {
         $rating_width = 100 - $rating_value / $rating_maximum * 100;
     }
     if ($rating_symbol == "other") {
         if ($rating_icon == "ts-ecommerce-starfull1") {
             $rating_class = 'ts-rating-stars-star1';
         } else {
             if ($rating_icon == "ts-ecommerce-starfull2") {
                 $rating_class = 'ts-rating-stars-star2';
             } else {
                 if ($rating_icon == "ts-ecommerce-starfull3") {
                     $rating_class = 'ts-rating-stars-star3';
                 } else {
                     if ($rating_icon == "ts-ecommerce-starfull4") {
                         $rating_class = 'ts-rating-stars-star4';
                     } else {
                         if ($rating_icon == "ts-ecommerce-heartfull") {
                             $rating_class = 'ts-rating-stars-heart1';
                         } else {
                             if ($rating_icon == "ts-ecommerce-heart") {
                                 $rating_class = 'ts-rating-stars-heart2';
                             } else {
                                 if ($rating_icon == "ts-ecommerce-thumbsup") {
                                     $rating_class = 'ts-rating-stars-thumb';
                                 } else {
                                     if ($rating_icon == "ts-ecommerce-ribbon4") {
                                         $rating_class = 'ts-rating-stars-ribbon';
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     } else {
//.........这里部分代码省略.........
开发者ID:ryansm,项目名称:saud,代码行数:101,代码来源:ts_vcsc_woocommerce_custom_rating.php

示例14: WooComposer_Loop_style04


//.........这里部分代码省略.........
        $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => $ids, 'field' => 'term_id', 'operator' => 'IN'));
    }
    $test = '';
    if (vc_is_inline()) {
        $test = "wcmp_vc_inline";
    }
    if ($product_animation == '') {
        $product_animation = 'no-animation';
    } else {
        $style .= 'opacity:1;';
    }
    if ($element == "grid") {
        $class = 'vc_span' . $columns . ' ';
    }
    $output .= '<div class="woocomposer ' . $test . '" data-columns="' . $col . '">';
    $query = new WP_Query($args);
    if ($query->have_posts()) {
        while ($query->have_posts()) {
            $query->the_post();
            $product_id = get_the_ID();
            $uid = uniqid();
            $output .= '<div id="product-' . $uid . '" style="' . $style . '" class="' . $class . ' wpb_column column_container wooproduct" data-animation="animated ' . $product_animation . '">';
            if ($element == 'carousel') {
                $output .= '<div class="wcmp-carousel-item">';
            }
            $product_title = get_the_title($product_id);
            $post = get_post($product_id);
            $product_desc = get_post($product_id)->post_excerpt;
            $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size);
            $product = new WC_Product($product_id);
            $attachment_ids = $product->get_gallery_attachment_ids();
            $price = $product->get_price_html();
            $rating = $product->get_rating_html();
            $attributes = $product->get_attributes();
            $stock = $product->is_in_stock() ? 'InStock' : 'OutOfStock';
            if ($product->is_on_sale()) {
                $on_sale = apply_filters('woocommerce_sale_flash', $label_on_sale, $post, $product);
            } else {
                $on_sale = '';
            }
            if ($quick_view_style == "expandable") {
                $quick_view_class = 'quick-view-loop';
            } else {
                $quick_view_class = 'quick-view-loop-popup';
            }
            $cat_count = sizeof(get_the_terms($product_id, 'product_cat'));
            $tag_count = sizeof(get_the_terms($product_id, 'product_tag'));
            $categories = $product->get_categories(', ', '<span class="posted_in">' . _n('', '', $cat_count, 'woocommerce') . ' ', '.</span>');
            $tags = $product->get_tags(', ', '<span class="tagged_as">' . _n('', '', $tag_count, 'woocommerce') . ' ', '.</span>');
            $output .= "\n" . '<div class="wcmp-product woocommerce wcmp-' . $product_style . ' ' . $img_animate . '" style="' . $border . ' ' . $desc_style . '">';
            $output .= "\n\t" . '<div class="wcmp-product-image">';
            if (empty($attachment_ids) && count($attachment_ids) > 1 && $product_img_disp == "carousel") {
                $uniqid = uniqid();
                $output .= '<div class="wcmp-single-image-carousel carousel-in-loop">';
                $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size);
                if ($lazy_images == "enable") {
                    $src = plugins_url('../assets/img/loader.gif', __FILE__);
                } else {
                    $src = $product_img[0];
                }
                $output .= '<div><div class="wcmp-image"><img class="wcmp-img" src="' . $src . '" data-src="' . $product_img[0] . '"/></div></div>';
                foreach ($attachment_ids as $attachment_id) {
                    $product_img = wp_get_attachment_image_src($attachment_id, $image_size);
                    if ($lazy_images == "enable") {
                        $src = plugins_url('../assets/img/loader.gif', __FILE__);
                    } else {
开发者ID:RDePoppe,项目名称:luminaterealestate,代码行数:67,代码来源:design-loop-style04.php

示例15: extract


//.........这里部分代码省略.........
         $css_class = $slider_class . ' ' . $el_class;
     }
     $output .= '<div id="' . $woo_slider_id . '-container" class="ts-woocommerce-slider-container">';
     // Add Progressbar
     if ($auto_play == "true" && $show_bar == "true" && $frontend_edit == "false") {
         $output .= '<div id="ts-owlslider-progressbar-' . $woo_random . '" class="ts-owlslider-progressbar-holder" style=""><div class="ts-owlslider-progressbar" style="background: ' . $bar_color . '; height: 100%; width: 0%;"></div></div>';
     }
     // Add Navigation Controls
     if ($frontend_edit == "false") {
         $output .= '<div id="ts-owlslider-controls-' . $woo_random . '" class="ts-owlslider-controls" style="' . ($auto_play == "true" || $show_navigation == "true" ? "display: block;" : "display: none;") . '">';
         $output .= '<div id="ts-owlslider-controls-next-' . $woo_random . '" style="' . ($show_navigation == "true" ? "display: block;" : "display: none;") . '" class="ts-owlslider-controls-next"><span class="ts-ecommerce-arrowright5"></span></div>';
         $output .= '<div id="ts-owlslider-controls-prev-' . $woo_random . '" style="' . ($show_navigation == "true" ? "display: block;" : "display: none;") . '" class="ts-owlslider-controls-prev"><span class="ts-ecommerce-arrowleft5"></span></div>';
         if ($auto_play == "true") {
             $output .= '<div id="ts-owlslider-controls-play-' . $woo_random . '" class="ts-owlslider-controls-play active"><span class="ts-ecommerce-pause"></span></div>';
         }
         $output .= '</div>';
     }
     // Front-Edit Message
     if ($frontend_edit == "true") {
         $output .= $slider_message;
     }
     // Add Slider
     $output .= '<div id="' . $woo_slider_id . '" class="' . $css_class . '" style="margin-top: ' . $margin_top . 'px; margin-bottom: ' . $margin_bottom . 'px;" data-id="' . $woo_random . '" data-items="' . $products_slide . '" data-breakpointscustom="' . $breakpoints_custom . '" data-breakpointitems="' . $breakpoints_items . '" data-rtl="' . $page_rtl . '" data-loop="' . $items_loop . '" data-navigation="' . $show_navigation . '" data-dots="' . $show_dots . '" data-mobile="' . $animation_mobile . '" data-animationin="' . $animation_in . '" data-animationout="' . $animation_out . '" data-height="' . $auto_height . '" data-play="' . $auto_play . '" data-bar="' . $show_bar . '" data-color="' . $bar_color . '" data-speed="' . $show_speed . '" data-hover="' . $stop_hover . '">';
     if ($loop->have_posts()) {
         while ($loop->have_posts()) {
             $loop->the_post();
             $product_id = get_the_ID();
             $product_title = get_the_title($product_id);
             $post = get_post($product_id);
             $product = new WC_Product($product_id);
             $attachment_ids = $product->get_gallery_attachment_ids();
             $price = $product->get_price_html();
             $product_sku = $product->get_sku();
             $attributes = $product->get_attributes();
             $stock = $product->is_in_stock() ? 'true' : 'false';
             $onsale = $product->is_on_sale() ? 'true' : 'false';
             // Rating Settings
             $rating_html = $product->get_rating_html();
             $rating = $product->get_average_rating();
             if ($rating == '') {
                 $rating = 0;
             }
             if ($rating_quarter == "true") {
                 $rating_value = floor($rating * 4) / 4;
             } else {
                 $rating_value = $rating;
             }
             $rating_value = number_format($rating_value, 2, $caption_digits, '');
             if ($rating_rtl == "false") {
                 $rating_width = $rating_value / $rating_maximum * 100;
             } else {
                 $rating_width = 100 - $rating_value / $rating_maximum * 100;
             }
             if ($rating_symbol == "other") {
                 if ($rating_icon == "ts-ecommerce-starfull1") {
                     $rating_class = 'ts-rating-stars-star1';
                 } else {
                     if ($rating_icon == "ts-ecommerce-starfull2") {
                         $rating_class = 'ts-rating-stars-star2';
                     } else {
                         if ($rating_icon == "ts-ecommerce-starfull3") {
                             $rating_class = 'ts-rating-stars-star3';
                         } else {
                             if ($rating_icon == "ts-ecommerce-starfull4") {
                                 $rating_class = 'ts-rating-stars-star4';
                             } else {
开发者ID:Telemedellin,项目名称:fonvalmed,代码行数:67,代码来源:ts_vcsc_woocommerce_custom_slider.php


注:本文中的WC_Product::get_attributes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。