Posts Categorized: Notes

Using jQuery for Spliting li list to three ul list and speparating them with hr

In short :

foo = [1,2,3,4,5,6,7,8];
alert(foo);
bar = foo.slice(3);
alert(bar);

and more complex example:

<ul class="products">
<li>object1</li>
<li>object2</li>
<li>object3</li>
<li>object4</li>
<li>object5</li>
<li>object6</li>
<li>object7</li>
<li>object8</li>
<li>object9</li>
<li>object10</li>
</ul>
//split ul into three parts with hr between
//add 2 uls after first one
//move lis into 2 uls
jQuery("li.product-cat-an-mala-mor").parent("ul").addClass("splitme");
	if(jQuery(".splitme").length > 0) {
		jQuery(".splitme").after('<hr class="product-separator"><ul class="products splitme2"></ul><hr class="product-separator"><ul class="products"></ul>');
		jQuery("ul.products").eq(1).append(jQuery(".splitme li").slice(3).detach());
		jQuery("ul.products").eq(2).append(jQuery(".splitme2 li").slice(2).detach());
		}

Because I using this on woocomerce shop, I was added extra class splittime with the if statement to make sure is all changes will work only in one category .

 

WooCommerce products ID

This code create a new column on the products list page that will show each product ID.

<?php
/**
 * Plugin Name: WooCommerce - Show products IDs
 * Plugin URI: http://www.remicorson.com/easily-find-woocommerce-products-id/
 * Description: Adds a new columns to products list page to display product IDs
 * Version: 1.0
 * Author: Remi Corson
 * Author URI: http://remicorson.com
 * Requires at least: 3.5
 * Tested up to: 3.5
 *
 * Text Domain: -
 * Domain Path: -
 *
 */
 
 /*
|--------------------------------------------------------------------------
| WooCommerce Product Extra Columns
|--------------------------------------------------------------------------
*/

/**
 * Load Custom Product Columns
 *
 * @access      public
 * @since       1.0 
 * @return      
*/
function woo_product_extra_columns($columns)
{

	$newcolumns = array(
		"cb"       		=> "<input type  = \"checkbox\" />",
		"product_ID"    => esc_html__('ID', 'woocommerce'),
	);

	$columns = array_merge($newcolumns, $columns);
	
	return $columns;
}
add_filter("manage_edit-product_columns", "woo_product_extra_columns");


/**
 * Charge Product Columns Content
 *
 * @access      public
 * @since       1.0 
 * @return      
*/
function woo_product_extra_columns_content($column)
{
	global $post;
	
	$product_id = $post->ID;

	switch ($column)
	{
		case "product_ID":
			echo $product_id;
		break;	
		
	}
}
add_action("manage_posts_custom_column",  "woo_product_extra_columns_content");