
เป็นปลั๊กอินที่ช่วยเอาไว้ ทำให้ WordPress สามารถขายสินค้าได้ มีระบบ Order , Products
Brand Taxonomy
add_action( 'init', 'add_brand_taxonomy_item');
function add_brand_taxonomy_item() {
$labels = array(
'name' => 'Brands',
'singular_name' => 'Brand',
'menu_name' => 'Brands',
'all_items' => 'All Brands',
'parent_item' => 'Parent Brand',
'parent_item_colon' => 'Parent Brand:',
'new_item_name' => 'New Brand Name',
'add_new_item' => 'Add New Brand',
'edit_item' => 'Edit Brand',
'update_item' => 'Update Brand',
'separate_items_with_commas' => 'Separate Brand with commas',
'search_items' => 'Search Brands',
'add_or_remove_items' => 'Add or remove Brands',
'choose_from_most_used' => 'Choose from the most used Brands',
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_admin_column' => true,
'show_in_nav_menus' => true,
'show_tagcloud' => true,
);
register_taxonomy( 'brand', 'product', $args );
}
การลบ URL ที่มี /
ลบ /page/1/ ใน /product-category/game/page/2/
add_filter('paginate_links', function ($link) {
return preg_replace('#page\/1[^\d]#', '', $link);
});
Admin Column
add_filter( 'manage_edit-shop_order_columns', 'test_function1' );
function test_function1( $columns ) {
$new_columns = ( is_array( $columns ) ) ? $columns : array();
unset( $new_columns[ 'order_actions' ] );
$new_columns['slip_column'] = 'test';
$new_columns[ 'order_actions' ] = $columns[ 'order_actions' ];
return $new_columns;
}
add_action( 'manage_shop_order_posts_custom_column' , 'test_function2' );
function test_function2( $column ) {
global $the_order;
global $wpdb;
if( $column == 'test' ) {
$order_id = $the_order->get_id();
}
}