function jigoshop_custom_product_columns($column) { global $post; $jigoshop_options = Jigoshop_Base::get_options(); $product = new jigoshop_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 jigoshop_get_product_thumbnail('admin_product_list'); echo '</a>'; } else { echo jigoshop_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=jigoshop-feature-product&product_id=' . $post->ID)); echo '<a href="' . esc_url($url) . '" title="' . __('Change', 'jigoshop') . '">'; if ($product->is_featured()) { echo '<a href="' . esc_url($url) . '"><img src="' . jigoshop::assets_url() . '/assets/images/head_featured_desc.png" alt="yes" />'; } else { echo '<img src="' . jigoshop::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', 'jigoshop'); } 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', 'jigoshop'); } else { echo $product->stock . ' ' . __('In Stock', 'jigoshop'); } } } else { echo __('In Stock', 'jigoshop'); } } elseif ($product->is_type('grouped')) { echo __('Parent (no stock)', 'jigoshop'); } else { echo '<strong class="attention">' . __('Out of Stock', 'jigoshop') . '</strong>'; } break; case "product-type": echo __(ucwords($product->product_type), 'jigoshop'); echo '<br/>'; if ($jigoshop_options->get('jigoshop_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', 'jigoshop'); $time_diff = 0; } else { $t_time = get_the_time(__('Y/m/d g:i:s A', 'jigoshop')); $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', 'jigoshop'), human_time_diff($time)); } else { $h_time = mysql2date(__('Y/m/d', 'jigoshop'), $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', 'jigoshop'); } elseif ('future' == $post->post_status) { if ($time_diff > 0) { echo '<strong class="attention">' . __('Missed schedule', 'jigoshop') . '</strong>'; } else { _e('Scheduled', 'jigoshop'); } } else { _e('Draft', 'jigoshop'); } 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; } }
/** * Execute changes made in Jigoshop 1.3 * * @since 1.3 */ function jigoshop_upgrade_130() { global $wpdb; /* Update all product variation titles to something useful. */ $args = array( 'post_type' => 'product', 'tax_query' => array( array( 'taxonomy'=> 'product_type', 'terms' => 'variable', 'field' => 'slug', 'operator'=> 'IN' ) ) ); $posts_array = get_posts( $args ); foreach ( $posts_array as $post ) { $product = new jigoshop_product ( $post->ID ); $var = $product->get_children(); foreach ( $var as $id ) { $variation = $product->get_child( $id )->variation_data; $taxes = array(); foreach ( $variation as $k => $v ) : if ( strstr ( $k, 'tax_' ) ) { $tax = substr( $k, 4 ); $taxes[] = sprintf('[%s: %s]', $tax, !empty($v) ? $v : 'Any ' . $tax ); } endforeach; if ( !strstr (get_the_title($id), 'Child Variation' ) ) continue; $title = sprintf('%s - %s', get_the_title($post->ID), implode( $taxes, ' ' ) ); if ( !empty($title) ) $wpdb->update( $wpdb->posts, array('post_title' => $title), array('ID' => $id) ); } } // Convert coupon options to new 'shop_coupon' custom post type and create posts $args = array( 'numberposts' => -1, 'post_type' => 'shop_coupon', 'post_status' => 'publish' ); $new_coupons = (array) get_posts( $args ); if ( empty( $new_coupons )) { /* probably an upgrade from 1.2.3 or less, convert options based coupons */ $coupons = get_option( 'jigoshop_coupons' ); $coupon_data = array( 'post_status' => 'publish', 'post_type' => 'shop_coupon', 'post_author' => 1, 'post_name' => '', 'post_content' => '', 'comment_status' => 'closed' ); if ( ! empty( $coupons )) foreach ( $coupons as $coupon ) { $coupon_data['post_name'] = $coupon['code']; $coupon_data['post_title'] = $coupon['code']; $post_id = wp_insert_post( $coupon_data ); update_post_meta( $post_id, 'type', $coupon['type'] ); update_post_meta( $post_id, 'amount', $coupon['amount'] ); update_post_meta( $post_id, 'include_products', $coupon['products'] ); update_post_meta( $post_id, 'date_from', ($coupon['date_from'] <> 0) ? $coupon['date_from'] : '' ); update_post_meta( $post_id, 'date_to', ($coupon['date_to'] <> 0) ? $coupon['date_to'] : '' ); update_post_meta( $post_id, 'individual_use', ($coupon['individual_use'] == 'yes') ); } } else { /* if CPT based coupons from RC1, convert data for incorrect products meta */ foreach ( $new_coupons as $id => $coupon ) { $product_ids = get_post_meta( $coupon->ID, 'products', true ); if ( $product_ids <> '' ) update_post_meta( $coupon->ID, 'include_products', $product_ids ); delete_post_meta( $coupon->ID, 'products', $product_ids ); } } flush_rewrite_rules( true ); }