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; } }
<?php do_action('fflcommerce_my_account_orders_thead'); ?> </tr> </thead> <tbody><?php $orders = new fflcommerce_orders(); $orders->get_customer_orders(get_current_user_id(), $recent_orders); if ($orders->orders) { foreach ($orders->orders as $order) { /** @var $order fflcommerce_order */ if ($order->status == 'pending') { foreach ($order->items as $item) { $_product = $order->get_product_from_item($item); $temp = new fflcommerce_product($_product->ID); if ($temp->managing_stock() && (!$temp->is_in_stock() || !$temp->has_enough_stock($item['qty']))) { $order->cancel_order(sprintf(__("Product - %s - is now out of stock -- Canceling Order", 'fflcommerce'), $_product->get_title())); ob_get_clean(); wp_safe_redirect(apply_filters('fflcommerce_get_myaccount_page_id', get_permalink(fflcommerce_get_page_id('myaccount')))); exit; } } } ?> <tr class="order"> <td><?php echo $order->get_order_number(); ?> </td> <td><time title="<?php echo esc_attr(date_i18n(get_option('date_format') . ' ' . get_option('time_format'), strtotime($order->order_date)));
/** * Stock Reports */ function fflcommerce_dash_stock_report() { if (FFLCommerce_Base::get_options()->get('fflcommerce_manage_stock') == 'yes') { $lowstockamount = FFLCommerce_Base::get_options()->get('fflcommerce_notify_low_stock_amount'); if (!is_numeric($lowstockamount)) { $lowstockamount = 1; } $nostockamount = FFLCommerce_Base::get_options()->get('fflcommerce_notify_no_stock_amount'); if (!is_numeric($nostockamount)) { $nostockamount = 0; } $outofstock = array(); $lowinstock = array(); /** @var $wpdb WPDB */ global $wpdb; // Download low in stock products $query = $wpdb->prepare("SELECT DISTINCT p.ID, p.post_parent FROM {$wpdb->posts} p\n\t\t\tLEFT JOIN {$wpdb->postmeta} pmm ON p.ID = pmm.post_id\n\t\t\tLEFT JOIN {$wpdb->postmeta} pms ON p.ID = pms.post_id\n\t\t\tLEFT JOIN {$wpdb->postmeta} pmb ON p.ID = pmb.post_id\n\t\t\tWHERE p.post_status = %s AND ((p.post_type = %s AND pmm.meta_value = 1 AND pmm.meta_key = %s AND pmb.meta_key = %s) OR p.post_type = %s) AND pms.meta_key = %s AND\n\t\t\t\t((pms.meta_value <= %d AND pms.meta_value > %d) OR (pms.meta_value = %d AND pmb.meta_value = %s))\n\t\t\t", array('publish', 'product', 'manage_stock', 'backorders', 'product_variation', 'stock', $lowstockamount, $nostockamount, $nostockamount, 'yes')); $results = $wpdb->get_results($query); foreach ($results as $item) { $id = $item->post_parent == 0 ? $item->ID : $item->post_parent; $lowinstock[] = array('link' => get_edit_post_link($id), 'title' => get_the_title($item->ID)); } // Download out of stock products $query = $wpdb->prepare("SELECT p.ID FROM {$wpdb->posts} p\n\t\t\tLEFT JOIN {$wpdb->postmeta} pmm ON p.ID = pmm.post_id AND pmm.meta_key = %s\n\t\t\tLEFT JOIN {$wpdb->postmeta} pms ON p.ID = pms.post_id AND pms.meta_key = %s\n\t\t\tLEFT JOIN {$wpdb->postmeta} pmb ON p.ID = pmb.post_id AND pmb.meta_key = %s\n\t\t\tWHERE p.post_type = %s AND p.post_status = %s AND pmm.meta_value = 1 AND pms.meta_value = %d AND pmb.meta_value <> %s\n\t\t\t", array('manage_stock', 'stock', 'backorders', 'product', 'publish', $nostockamount, 'yes')); $results = $wpdb->get_results($query); foreach ($results as $id) { $product = new fflcommerce_product($id->ID); if (!$product->is_in_stock(true)) { $outofstock[] = array('link' => get_edit_post_link($id->ID), 'title' => get_the_title($id->ID)); } } $outofstock = array_splice($outofstock, 0, 20); $lowinstock = array_splice($lowinstock, 0, 20); ?> <div id="fflcommerce_right_now" class="fflcommerce_right_now"> <div class="table table_content"> <p class="sub"><?php _e('Low Stock', 'fflcommerce'); ?> </p> <ol> <?php if (count($lowinstock) > 0) { ?> <?php foreach ($lowinstock as $item) { ?> <li><a href="<?php echo $item['link']; ?> "><?php echo $item['title']; ?> </a></li> <?php } ?> <?php } else { ?> <li><?php echo __('No products are low in stock.', 'fflcommerce'); ?> </li> <?php } ?> </ol> </div> <div class="table table_discussion"> <p class="sub"><?php _e('Out of Stock/Backorders', 'fflcommerce'); ?> </p> <ol> <?php if (count($outofstock) > 0) { ?> <?php foreach ($outofstock as $item) { ?> <li><a href="<?php echo $item['link']; ?> "><?php echo $item['title']; ?> </a></li> <?php } ?> <?php } else { ?> <li><?php echo __('No products are out of stock.', 'fflcommerce'); ?> </li> <?php } ?> </ol> </div> <br class="clear" /> </div> <?php } }
function fflcommerce_custom_product_columns($column) { global $post; $fflcommerce_options = FFLCommerce_Base::get_options(); $product = new fflcommerce_product($post->ID); switch ($column) { case "thumb": if ('trash' != $post->post_status) { echo '<a class="row-title" href="' . get_edit_post_link($post->ID) . '">'; echo fflcommerce_get_product_thumbnail('admin_product_list'); echo '</a>'; } else { echo fflcommerce_get_product_thumbnail('admin_product_list'); } break; case "price": echo $product->get_price_html(); break; case "featured": $url = wp_nonce_url(admin_url('admin-ajax.php?action=fflcommerce-feature-product&product_id=' . $post->ID)); echo '<a href="' . esc_url($url) . '" title="' . __('Change', 'fflcommerce') . '">'; if ($product->is_featured()) { echo '<a href="' . esc_url($url) . '"><img src="' . fflcommerce::assets_url() . '/assets/images/head_featured_desc.png" alt="yes" />'; } else { echo '<img src="' . fflcommerce::assets_url() . '/assets/images/head_featured.png" alt="no" />'; } echo '</a>'; break; case "stock": if (!$product->is_type('grouped') && $product->is_in_stock()) { if ($product->managing_stock()) { if ($product->is_type('variable') && $product->stock > 0) { echo $product->stock . ' ' . __('In Stock', 'fflcommerce'); } else { if ($product->is_type('variable')) { $stock_total = 0; foreach ($product->get_children() as $child_ID) { $child = $product->get_child($child_ID); $stock_total += (int) $child->stock; } echo $stock_total . ' ' . __('In Stock', 'fflcommerce'); } else { echo $product->stock . ' ' . __('In Stock', 'fflcommerce'); } } } else { echo __('In Stock', 'fflcommerce'); } } elseif ($product->is_type('grouped')) { echo __('Parent (no stock)', 'fflcommerce'); } else { echo '<strong class="attention">' . __('Out of Stock', 'fflcommerce') . '</strong>'; } break; case "product-type": echo __(ucwords($product->product_type), 'fflcommerce'); echo '<br/>'; if ($fflcommerce_options->get('fflcommerce_enable_sku', true) == 'yes' && ($sku = get_post_meta($post->ID, 'sku', true))) { echo $sku; } else { echo $post->ID; } break; case "product-date": if ('0000-00-00 00:00:00' == $post->post_date) { $t_time = $h_time = __('Unpublished', 'fflcommerce'); $time_diff = 0; } else { $t_time = get_the_time(__('Y/m/d g:i:s A', 'fflcommerce')); $m_time = $post->post_date; $time = get_post_time('G', true, $post); $time_diff = time() - $time; if ($time_diff > 0 && $time_diff < 24 * 60 * 60) { $h_time = sprintf(__('%s ago', 'fflcommerce'), human_time_diff($time)); } else { $h_time = mysql2date(__('Y/m/d', 'fflcommerce'), $m_time); } } echo '<abbr title="' . esc_attr($t_time) . '">' . apply_filters('post_date_column_time', $h_time, $post) . '</abbr><br />'; if ('publish' == $post->post_status) { _e('Published', 'fflcommerce'); } elseif ('future' == $post->post_status) { if ($time_diff > 0) { echo '<strong class="attention">' . __('Missed schedule', 'fflcommerce') . '</strong>'; } else { _e('Scheduled', 'fflcommerce'); } } else { _e('Draft', 'fflcommerce'); } if ($product->visibility) { echo $product->visibility != 'visible' ? '<br /><strong class="attention">' . ucfirst($product->visibility) . '</strong>' : ''; } break; case "product-visibility": if ($product->visibility) { echo $product->visibility == 'Hidden' ? '<strong class="attention">' . ucfirst($product->visibility) . '</strong>' : ucfirst($product->visibility); } break; } }