Пример #1
0
    public function column_default($item, $column_name)
    {
        global $product;
        if (!$product || $product->id !== $item->id) {
            $product = new fflcommerce_product($item->id);
        }
        switch ($column_name) {
            case 'product':
                if ($sku = $product->get_sku()) {
                    echo $sku . ' - ';
                }
                echo $product->get_title();
                // Get variation data
                if ($product->is_type('variation')) {
                    $list_attributes = array();
                    $attributes = $product->get_available_attributes_variations();
                    foreach ($attributes as $name => $attribute) {
                        $list_attributes[] = $product->attribute_label(str_replace('pa_', '', $name)) . ': <strong>' . $attribute . '</strong>';
                    }
                    echo '<div class="description">' . implode(', ', $list_attributes) . '</div>';
                }
                break;
            case 'parent':
                if ($item->parent) {
                    echo get_the_title($item->parent);
                } else {
                    echo '-';
                }
                break;
            case 'stock_status':
                if ($product->is_in_stock() || !isset($product->meta['stock_manage']) && !isset($product->meta['stock_status']) && $product->get_stock() > 0) {
                    echo '<mark class="instock">' . __('In stock', 'fflcommerce') . '</mark>';
                } else {
                    echo '<mark class="outofstock">' . __('Out of stock', 'fflcommerce') . '</mark>';
                }
                break;
            case 'stock_level':
                echo $product->get_stock();
                break;
            case 'actions':
                ?>
<p>
				<?php 
                $actions = array();
                $action_id = $item->parent != 0 ? $item->parent : $item->id;
                $actions['edit'] = array('url' => admin_url('post.php?post=' . $action_id . '&action=edit'), 'name' => __('Edit', 'fflcommerce'), 'action' => "edit");
                if ($product->is_visible()) {
                    $actions['view'] = array('url' => get_permalink($action_id), 'name' => __('View', 'fflcommerce'), 'action' => "view");
                }
                $actions = apply_filters('fflcommerce_admin_stock_report_product_actions', $actions, $product);
                foreach ($actions as $action) {
                    printf('<a class="button tips %s" href="%s" data-tip="%s ' . __('product', 'fflcommerce') . '">%s</a>', $action['action'], esc_url($action['url']), esc_attr($action['name']), esc_attr($action['name']));
                }
                ?>
				</p><?php 
                break;
        }
    }
 public function get_stock()
 {
     $stock = get_post_meta($this->variation_id, 'stock', true);
     if (empty($stock) || $stock == '-9999999') {
         $stock = parent::get_stock();
     }
     return (int) $stock;
 }