Nsp Code https://www.nsp-code.com Premium WordPress Development Sat, 09 Jun 2018 15:44:55 +0000 en-US hourly 1 https://wordpress.org/?v=4.9.6 Sort WooCommerce Products while automatically put the Out of Stock items at the end of list https://www.nsp-code.com/sort-woocommerce-products-while-automatically-put-the-out-of-stock-items-at-the-end-of-list/ https://www.nsp-code.com/sort-woocommerce-products-while-automatically-put-the-out-of-stock-items-at-the-end-of-list/#respond Thu, 10 May 2018 16:20:58 +0000 https://www.nsp-code.com/?p=15424 Sorting for WooCommerce Products is a simple process, the Advanced Post Types Order cover all possibilities to cover any type of sorting automation or manual drag&drop. The WooCommerce – Sort Products which belong to multiple categories cover the basics to get started. Already sorted WooCommerce products, are displayed accordingly on front side. Many shop owners […]

The post Sort WooCommerce Products while automatically put the Out of Stock items at the end of list appeared first on Nsp Code.

]]>
Sorting for WooCommerce Products is a simple process, the Advanced Post Types Order cover all possibilities to cover any type of sorting automation or manual drag&drop. The WooCommerce – Sort Products which belong to multiple categories cover the basics to get started.

Already sorted WooCommerce products, are displayed accordingly on front side. Many shop owners chose to promote marketable items by sorting the list and put on top of everything else. This is a smart technique which greatly increase visibility and imply revenue excedent. Often, Out of Stock products can be a pain and require sort adjustments to lower priority in the list and show at the bottom of it.

The Advanced Post Types Order plugin can help with that, through a custom code it provides the automation process to put any products in the list which are Out of Order at the end of the list. The sort list will be kept as is (per administrator customization), only when displayed, the products with no stock will be moved at the end of the grid.

The following code can be included in theme functions.php or within a custom plugin:

     add_filter('apto_get_order_list', 'custom_wooc_apto_get_order_list', 10, 2);
    function custom_wooc_apto_get_order_list( $order_list, $sort_view_id )
        {
            
            //not for admin, only for Front Side
            if ( is_admin() )
                return $order_list;    
                
            global $APTO;
            
            //retrieve the sort post
            $sort_view_data     =   get_post($sort_view_id);
            $sortID             =   $sort_view_data->post_parent;   
            
            //check if is a woocommerce sort
            if ( ! $APTO->functions->is_woocommerce($sortID) )
                return $order_list;
            
            //identify the products out of stock
            $out_of_stock   =   array();
            
            foreach ( $order_list   as  $key    =>  $post_id ) 
                {
                    if ( get_post_meta($post_id, '_manage_stock', TRUE )    !=  'yes' )
                        continue;
                        
                    if ( get_post_meta($post_id, '_stock', TRUE)    <   1 )
                        {
                            $out_of_stock[] =   $post_id;
                            unset(  $order_list[$key] );
                        }
                }
                
            //re-index the keys
            $order_list =   array_values($order_list);
            
            //put the OutOf Stock at the end of list
            if ( count ( $out_of_stock )  >   0 )
                {
                    foreach (   $out_of_stock   as  $post_id    )
                        {
                            $order_list[]   =   $post_id;   
                        }
                }
            
            return $order_list;
            
        }

The post Sort WooCommerce Products while automatically put the Out of Stock items at the end of list appeared first on Nsp Code.

]]>
https://www.nsp-code.com/sort-woocommerce-products-while-automatically-put-the-out-of-stock-items-at-the-end-of-list/feed/ 0
How to retrieve the sticky posts for a sort https://www.nsp-code.com/how-to-retrieve-the-sticky-posts-for-a-sort/ https://www.nsp-code.com/how-to-retrieve-the-sticky-posts-for-a-sort/#respond Tue, 24 Apr 2018 16:32:13 +0000 https://www.nsp-code.com/?p=15338 The default WordPress Sticky functionality is very limited. It allows to put a post on top of the list which is pretty much everything about it. Beside other missing functionality, there is no control over order, making the list totally uncontrollable. The Advanced Post Types Order plugin provides a similar internal Sticky Posts, which is […]

The post How to retrieve the sticky posts for a sort appeared first on Nsp Code.

]]>
The default WordPress Sticky functionality is very limited. It allows to put a post on top of the list which is pretty much everything about it. Beside other missing functionality, there is no control over order, making the list totally uncontrollable.

The Advanced Post Types Order plugin provides a similar internal Sticky Posts, which is very flexible and preferable to be used instead default.

Sticky Posts are adjusted/applyed automatically on front side, on a query run. Programmatically retrieval for those posts is also easy, the following code can be used:

    $attr = array(
                        '_view_selection'   =>  'taxonomy',
                        '_taxonomy'         =>  $taxonomy_name,
                        '_term_id'          =>  $term_id
                        );
    
    $sort_view_id   =   $APTO->functions->get_sort_view_id_by_attributes($sort_id, $attr);
    $sticky_list = get_post_meta( $sort_view_id , '_sticky_data', TRUE);

or for archive type

    $attr = array(
                        '_view_selection'   =>  'archive'
                        );
    
    $sort_view_id   =   $APTO->functions->get_sort_view_id_by_attributes($sort_id, $attr);
    $sticky_list = get_post_meta( $sort_view_id , '_sticky_data', TRUE);

The returned $sticky_list is an array containing the list of sticky posts. The key of array element is the position within the list and the value is the object_id.

The post How to retrieve the sticky posts for a sort appeared first on Nsp Code.

]]>
https://www.nsp-code.com/how-to-retrieve-the-sticky-posts-for-a-sort/feed/ 0
How to sort posts automatically by a Last Name included in title https://www.nsp-code.com/sort-posts-automatically-last-name-included-title/ https://www.nsp-code.com/sort-posts-automatically-last-name-included-title/#respond Wed, 11 Apr 2018 19:27:36 +0000 https://www.nsp-code.com/?p=15288 Automated sorting is always a fast way to maintain ordering without any admin intervention Automatic Order. In this particular scenario, the post titles include a person full name, we need to use the last name to create an automatic ordering. Once we set-up a sort, we switch to Automatic Order and use the Custom Function […]

The post How to sort posts automatically by a Last Name included in title appeared first on Nsp Code.

]]>
Automated sorting is always a fast way to maintain ordering without any admin intervention Automatic Order.

In this particular scenario, the post titles include a person full name, we need to use the last name to create an automatic ordering.

Once we set-up a sort, we switch to Automatic Order and use the Custom Function Callback functionality.

 

In this example the callback function name is called “custom_sorting_function_sort_by_last_name”, this should be placed in above field. The function should be included within theme functions.php or a custom plugin:

function custom_sorting_function_sort_by_last_name( $posts_list, $sort_view_id, $orderBy, $query)
        {
            $list_map   =   array();
            foreach($posts_list  as  $object_id)
                {
                    $object =   get_post($object_id);
                    
                    $name   =   explode(" ", $object->post_title);
                    
                    //remove empty spaces
                    $name   =   array_filter($name);
                    
                    if ( count  ($name)  > 0 )
                        {
                            end($name);
                            $list_map[$object_id]   =   current($name);
                        }
                }
                 
            //sort the dates ascending
            asort($list_map);
             
            $post_list  =   array_keys($list_map);
                 
            return $post_list;  
        }

The post How to sort posts automatically by a Last Name included in title appeared first on Nsp Code.

]]>
https://www.nsp-code.com/sort-posts-automatically-last-name-included-title/feed/ 0
Sort post objects assigned to a taxonomy terms but not it’s children https://www.nsp-code.com/sort-post-objects-assigned-taxonomy-terms-not-children/ https://www.nsp-code.com/sort-post-objects-assigned-taxonomy-terms-not-children/#respond Mon, 12 Mar 2018 16:34:38 +0000 https://www.nsp-code.com/?p=15146 Per WordPress Codex when creating a custom query, and request objects which belong to a specific term, direct assigned objects will be included. Also all other objects which belong to child terms related to queried term will be returned too. This is the default behavior observed within WordPress dashboard, when filter for a specific category, […]

The post Sort post objects assigned to a taxonomy terms but not it’s children appeared first on Nsp Code.

]]>
Per WordPress Codex when creating a custom query, and request objects which belong to a specific term, direct assigned objects will be included. Also all other objects which belong to child terms related to queried term will be returned too. This is the default behavior observed within WordPress dashboard, when filter for a specific category, all posts assigned to the term and it’s child will be show.

For example, we have a Blog category and a child Subcategory.

When filter for posts which are assigned to Blog, the dashboard also include posts assigned to it’s child Subcategory:

From above image, it can be seen that actually only 3 posts are direct objects of Blog category.

The explained practice works quite well in custom codes (themes and plugins), is the default way WordPress Query core works. The Advanced Post Types Order plugin, does just that and follow the standards.

What if we need to sort only object assigned to a taxonomy term but not it’s children?

The WordPress Codex mention a special parameter to make that happen, called include_children. This is set to TRUE as default, if being used within a custom query as FALSE, it returns only direct objects only.
The Advanced Post Types Order plugin include support for such parameter, so it let to chose through the sort settings if the children are actually required to be show, on not. Depending on the setting, the sort list include (or not) the children objects and it will apply on front side for queries which match that parameter, accordingly.

Here’s a sample code which use the include_children:

    $args = array(
                'post_type'                 => 'post',
                'tax_query'                 => array(
                                                array(
                                                    'taxonomy'          => 'category',
                                                    'field'             => 'term_id',
                                                    'terms'             => array(2),
                                                    'include_children'  =>  FALSE
                                                    )
                                                )
                );

    $query = new WP_Query($args);

The post Sort post objects assigned to a taxonomy terms but not it’s children appeared first on Nsp Code.

]]>
https://www.nsp-code.com/sort-post-objects-assigned-taxonomy-terms-not-children/feed/ 0
How to randomize the first 10 posts in a manually sorted list https://www.nsp-code.com/randomize-first-10-posts-manually-sorted-list/ https://www.nsp-code.com/randomize-first-10-posts-manually-sorted-list/#respond Wed, 07 Mar 2018 22:02:04 +0000 https://www.nsp-code.com/?p=15129 The first step will be to create a sort which match a specif area of the site. Any sort type can be used either simple sort or mix of taxonomies and post types. Further, the following code should be placed inside theme functions.php or a custom plugin. The $SORT_TO_MATCH ne to be changed with the […]

The post How to randomize the first 10 posts in a manually sorted list appeared first on Nsp Code.

]]>
The first step will be to create a sort which match a specif area of the site. Any sort type can be used either simple sort or mix of taxonomies and post types.

Further, the following code should be placed inside theme functions.php or a custom plugin. The $SORT_TO_MATCH ne to be changed with the sort ID previously created, also $RANDOMIZE_FIRST_X_POSTS should contain the number of posts to randomize:

    add_filter('apto_get_order_list', 'custom_apto_get_order_list', 10, 2);
    function custom_apto_get_order_list( $order_list, $sort_view_id )
        {
            
            $SORT_TO_MATCH              =   121;
            $RANDOMIZE_FIRST_X_POSTS    =   10;
            
            $sort_view_post =   get_post( $sort_view_id );
            
            if ( $sort_view_post->post_parent   !=  $SORT_TO_MATCH)
                return $order_list;
            
            //randomize the first 10 posts
            $slice  =   array_slice( $order_list, 0, $RANDOMIZE_FIRST_X_POSTS);
            shuffle( $slice );
            
            //add the values
            foreach  ( array_values($slice) as $key    =>  $value)
                {
                    $order_list[$key]   =   $value;
                }
            
            return $order_list;
        }

The post How to randomize the first 10 posts in a manually sorted list appeared first on Nsp Code.

]]>
https://www.nsp-code.com/randomize-first-10-posts-manually-sorted-list/feed/ 0
Update the sorts when changing the site default language https://www.nsp-code.com/update-sorts-changing-site-default-language/ https://www.nsp-code.com/update-sorts-changing-site-default-language/#respond Tue, 06 Mar 2018 14:32:32 +0000 https://www.nsp-code.com/?p=15118 To allow sorting for different languages through custom plugins like WPML the plugin implemented a custom functionality which also save the sort language. The feature becomes active right after plugin activation, even if there’s no multilingual code active yet to preserve sorts compatibility for later usage. As default the Advanced Post Types Order plugin use […]

The post Update the sorts when changing the site default language appeared first on Nsp Code.

]]>
To allow sorting for different languages through custom plugins like WPML the plugin implemented a custom functionality which also save the sort language. The feature becomes active right after plugin activation, even if there’s no multilingual code active yet to preserve sorts compatibility for later usage.

As default the Advanced Post Types Order plugin use the site default language when saving the language attribute. If for some reason, the site language is being changed, apparently the orders does not apply anymore. This is an expected result, since the sorts where created for a particular language, which now has changed. There is a workaround for such scenario:

  1. Re-create the ordering, they will be save using the new language attribute and apply accordingly.
  2. Update the old language to new one within the sorts.

To update the language attribute within the sorts, the following code can be used. This code should be placed within a file and saved within WordPress root. Or if copied over into different directory, the include(‘wp-config.php’) line should be adjusted accordingly.

The _APTO_OLD_LANGUAGE_CODE constant should include the old language code. The _APTO_NEW_LANGUAGE_CODE need to held the new one.

    //define the constants
    define ('_APTO_OLD_LANGUAGE_CODE', 'en');
    define ('_APTO_NEW_LANGUAGE_CODE', 'de');
    
    include('wp-config.php');
    
    global $post;
    
    $args   =   array(
                        'post_type'         =>  'apto_sort',
                        'post_parent'       =>  '0',
                        'posts_per_page'    =>  -1
                        );
    $custm_query        =   new WP_Query( $args );
    while( $custm_query->have_posts() )
        {
            $custm_query->the_post();   
            
            //get all sort views
            $args   =   array(
                                'post_type'         =>  'apto_sort',
                                'post_parent'       =>  $post->ID,
                                'posts_per_page'    =>  -1  
                                );
            $sort_views =   get_posts( $args );
            if ( count ( $sort_views ) < 1 ) 
                continue;
                
            foreach ( $sort_views   as  $sort_view) 
                {
                    $_view_language =   get_post_meta( $sort_view->ID, '_view_language', TRUE );
                    if ( $_view_language !=  _APTO_OLD_LANGUAGE_CODE )
                        continue;
                        
                    update_post_meta( $sort_view->ID, '_view_language', _APTO_NEW_LANGUAGE_CODE );
                    
                }
            
        }

The post Update the sorts when changing the site default language appeared first on Nsp Code.

]]>
https://www.nsp-code.com/update-sorts-changing-site-default-language/feed/ 0
Add numbers to items within the sort list interface https://www.nsp-code.com/add-numbers-items-within-sort-list-interface/ https://www.nsp-code.com/add-numbers-items-within-sort-list-interface/#respond Fri, 23 Feb 2018 15:16:19 +0000 https://www.nsp-code.com/?p=15073 The Advanced Post Types Order plugin is based on jQuery Sortable UI to implement the drag & drop interface. As default this use the Unordered List tag (ul). For better control, some users might find easier to see ordered list (ol) instead which output numbers for each item in the list, accordingly to position in […]

The post Add numbers to items within the sort list interface appeared first on Nsp Code.

]]>
The Advanced Post Types Order plugin is based on jQuery Sortable UI to implement the drag & drop interface. As default this use the Unordered List tag (ul). For better control, some users might find easier to see ordered list (ol) instead which output numbers for each item in the list, accordingly to position in the group.

The interface become to the following:

This require a filter usage and a bit of code :

    add_filter('apto/sort_interface/list_type_tag', 'apto_sort_interface_list_type_tag');
    function apto_sort_interface_list_type_tag( $list_type_tag )
        {
            
            $list_type_tag   =   'ol';
            
            return $list_type_tag;
            
        }

The custom code should be placed inside theme functions.php or within a custom plugin.

The post Add numbers to items within the sort list interface appeared first on Nsp Code.

]]>
https://www.nsp-code.com/add-numbers-items-within-sort-list-interface/feed/ 0
How to sort posts automatically by a number/year included in title https://www.nsp-code.com/sort-posts-automatically-number-year-included-title/ https://www.nsp-code.com/sort-posts-automatically-number-year-included-title/#respond Wed, 07 Feb 2018 22:12:09 +0000 https://www.nsp-code.com/?p=14986 Manual sorting is a fun process, order adjustments are easy through the Advanced Post Types Order plugin drag & drop interface. Automatisation is possible through Automatic Order functionality. This provides a powerful set-up for creating algorithmic based sorting without a human intervention. For large list, this might be a good option to save good time […]

The post How to sort posts automatically by a number/year included in title appeared first on Nsp Code.

]]>
Manual sorting is a fun process, order adjustments are easy through the Advanced Post Types Order plugin drag & drop interface. Automatisation is possible through Automatic Order functionality. This provides a powerful set-up for creating algorithmic based sorting without a human intervention. For large list, this might be a good option to save good time spent on manual sorting adjustments.

For some sites, the post title ( or any other post data like content, excerpt etc ) might contain important information on which a sort is required to apply. For example a year number can be included in the title e.g.:
– Canada 1978 edition
– Spain 2000 issues
– Early Belgium 2003 fabric
– Bohemia and Moravia 1944 history

Sorting ascending by the year in titles can be done manually, however automatisation is easy achievable through Custom Function Callback and a bit of code.

 

In this particular example the callback function name is called “custom_sorting_function_sort_by_number_in_title”. The function should be included within theme functions.php or a custom plugin:

function custom_sorting_function_sort_by_number_in_title( $posts_list, $sort_view_id, $orderBy, $query)
        {
            $list_map   =   array();
            foreach($posts_list  as  $object_id)
                {
                    $object =   get_post($object_id);
                    
		    //extract the title using a regex	
                    preg_match('/\d{4}/', $object->post_title, $match );
                    
                    if ( $match  != FALSE )
                        $list_map[$object_id]   =   $match[0];    
                        else
                        $list_map[$object_id]   =   '';
                }
                 
            //sort the dates ascending
            arsort($list_map, SORT_NUMERIC);
             
            $post_list  =   array_keys($list_map);
                 
            return $post_list;  
        }

The post How to sort posts automatically by a number/year included in title appeared first on Nsp Code.

]]>
https://www.nsp-code.com/sort-posts-automatically-number-year-included-title/feed/ 0
How to copy an order list from a category to another https://www.nsp-code.com/copy-order-list-category-another/ https://www.nsp-code.com/copy-order-list-category-another/#respond Wed, 07 Feb 2018 16:59:39 +0000 https://www.nsp-code.com/?p=14974 Customizing order of posts within categories is an easy task through Advanced Post Types Order plugin. The self explanatory interface featuring a drag & drop functionality makes sorting a breeze. For large posts lists, order customize can take a bit of time, unless use automatic ordering. Manual sorting require drag & drop for individual posts […]

The post How to copy an order list from a category to another appeared first on Nsp Code.

]]>
Customizing order of posts within categories is an easy task through Advanced Post Types Order plugin. The self explanatory interface featuring a drag & drop functionality makes sorting a breeze.

For large posts lists, order customize can take a bit of time, unless use automatic ordering. Manual sorting require drag & drop for individual posts in the list, up and down, Multiple Posts Selection can be done to speed up the process.

A category sorting (or any other taxonomy term) can be migrated to another one by a simple push of a button. This is useful when posts exists in booth terms and order is required to be the same, or similar (allow further adjustments).

There is a “Copy this sort to” option at the end of drag & drop list, which allow list order to apply o the other side.

To achieve this functionality, the following code is required. This can be placed inside theme functions.php or within a custom plugin.

add_action('APTO/re-order-interface/footer-html','apto_reorder_interface_copy_sort');
    function apto_reorder_interface_copy_sort( $sort_view_id )
        {
            
            $sort_view_settings =  APTO_functions::get_sort_view_settings($sort_view_id);
            $sort_view_post     =  get_post($sort_view_id);
            $sort_ID            =  $sort_view_post->post_parent;
            
            
            ?>
            <style>
                .major-publishing-actions  p {margin: 0px}
                #apto_sort_copy img.process_image  {display: none} 
            </style>
            <div class="alignleft actions" id="apto_sort_copy"> 
                <p>Copy this sort to 
                <select name="apto_sort_copy_to" id="apto_sort_copy_to">
                    <?php
                    
                    $args  =  array(
                                        'post_type'    =>  'apto_sort',
                                        'post_parent'  =>  $sort_ID
                                        );
                    $custom_query      =  new WP_Query( $args );
                    
                    //make a sorted list of items
                    $sort_view_list =  array();
                    foreach($custom_query->posts    as  $found_sort_view_post)
                        {
                            $sort_view_post_details =  APTO_functions::get_sort_view_settings( $found_sort_view_post->ID );      
                            
                            if(empty($sort_view_post_details['_term_id']))
                                continue;
                                
                            if($sort_view_post->ID ==  $found_sort_view_post->ID)
                                continue;
                            
                            $term_data  =  get_term_by('id', $sort_view_post_details['_term_id'], $sort_view_post_details['_taxonomy']);
                            $sort_view_list[ $sort_view_post_details['_taxonomy'] ][ $found_sort_view_post->ID ]  =  $term_data->name;
                        }
                        
                    
                    foreach($sort_view_list    as  $taxonomy_name  =>  $data)
                        {
                            
                            asort($data);
                            
                            foreach($data  as  $sort_view_id    =>  $term_name)
                                {
                            
                                    ?>
                                    <option value="<?php echo $sort_view_id ?>"><?php echo ucfirst($taxonomy_name) ?> - <?php echo $term_name ?></option>
                                    <?php  
                                } 
                            
                        }
                    
                    ?>
                </select> <a href="javascript: void(0)" class="button-secondary" id="apto_sort_copy_button" onClick="apto_sort_copy_confirmSubmit()">Copy</a> <img alt="" src="<?php echo APTO_URL ?>/images/wpspin_light.gif" class="process_image"></p>
                
                <script type="text/javascript">
                                      
                    function apto_sort_copy_confirmSubmit()
                        {
                            var agree=confirm("Are you sure you want to copy this sort? All orders will be lost on the other side.");
                            if (agree)
                                {
                                    
                                    jQuery('#apto_sort_copy img.process_image').show();
                                    
                                    var queryString = { 
                                                    action:            'apto_sort_copy', 
                                                    sort_view_id:        sort_view_id,
                                                    copy_to:            jQuery('#apto_sort_copy_to').val(),
                                                    nonce:              '<?php echo wp_create_nonce( 'apto_sort_copy-' . get_current_user_id()) ?>'
                                                        };
                                    
                                    jQuery.ajax({
                                              type: 'POST',
                                              url: ajaxurl,
                                              data: queryString,
                                              cache: false,
                                              dataType: "html",
                                              success: function(response){
                                                jQuery('#apto_sort_copy img.process_image').hide();
                                                alert('Sort successfully copied');
                                              },
                                              error: function(html){
                                                jQuery('#apto_sort_copy img.process_image').hide();
                                                  }
                                            });    
                                }
                                else
                                {
                                    return false ;
                                }
                        }
                            
                </script>
                
            </div>
            
            <?php  
            
            
            
        }
        
    add_action( 'wp_ajax_apto_sort_copy', 'wp_ajax_apto_sort_copy' );
    function wp_ajax_apto_sort_copy()
        {
            
            //check for nonce
            if(! wp_verify_nonce($_POST['nonce'],  'apto_sort_copy-' . get_current_user_id()))
                {
                    _e( 'Invalid Nonce', 'apto' );
                    die();  
                }  
            
            $sort_view_id  =  $_POST['sort_view_id'];
            $copy_to        =  $_POST['copy_to'];
            
            global $wpdb;
            
            $query = "DELETE FROM `". $wpdb->prefix ."apto_sort_list`
                            WHERE `sort_view_id`    =  ". $copy_to;
            $results = $wpdb->get_results($query);
            
            //retrieve the sort list
            $query  =  "SELECT object_id FROM `". $wpdb->prefix ."apto_sort_list`
                            WHERE sort_view_id  = '". $sort_view_id ."'";
            $results        =  $wpdb->get_results( $query );
            
            if(count($results)  <  1)
                die();
            
            $query = "INSERT INTO `". $wpdb->prefix ."apto_sort_list` 
                        (`sort_view_id`, `object_id`) 
                        VALUES ";
            
            $sort_list  =  array();
            $first      =  TRUE;
            foreach($results    as  $result)
                {
                    
                    if($first  === FALSE)
                        $query  .=  ', ';
                        
                    $query  .= " ('" . $copy_to . "', '" . $result->object_id . "') ";
                    
                    $first  =  FALSE;
                    
                }
                    
            $results = $wpdb->get_results( $query );
            
            die();
            
        }

The post How to copy an order list from a category to another appeared first on Nsp Code.

]]>
https://www.nsp-code.com/copy-order-list-category-another/feed/ 0
WooCommerce – Sort Products which belong to multiple categories https://www.nsp-code.com/woocommerce-sort-products-which-belong-to-multiple-categories/ https://www.nsp-code.com/woocommerce-sort-products-which-belong-to-multiple-categories/#comments Mon, 05 Feb 2018 02:55:40 +0000 https://www.nsp-code.com/?p=602 An easy way to sort products which belong to multiple categories while keeping the previously order set for other places. This will ensure no order list is lost while a new sort is built.
Everything it's done though an intuitive drag and drop interface.

The post WooCommerce – Sort Products which belong to multiple categories appeared first on Nsp Code.

]]>
woo-commerce-logo

Probably the best choice for e-commerce under a WordPress environment, WooCommerce deliver all the juice you need for a successfully e-commerce business.  WooCommerce is built using WordPress best practices both on the front and the back end. This results in an efficient, robust and intuitive plugin.

Product Sorting has been introduced reticently, as an easy method of order customization, this can be done using a drag and drop interface which is similar to default WordPress admin  Products archive. This is a great way for keeping the best selling products on top of the list, which will give a boost to sales . Any decent shop will always use categories to keep the products in one place and make easier access to a certain type of goods. The product sorting can be done for each category using the filter that the admin sort interface display in the first part.

Using other plugins, why my order list broke for a category while i was doing another sorting for a different one?

For all other plugins, the product sorting rely on the default menu_order property, which unfortunate can keep only a value  at a time. Giving that  if a product belong to multiple categories, only the very last sorting order value will be held, everything else will be overwrite. In other words,  if you set a sorting for the products which belong to a category, going to the next one will remove the order you set previously. Obliviously we don’t want that, as every category is required to use a very specific order to achieve planned results. Advanced Post Types Order is a specialized application, the perfect tool for managing the product sorting while keeping the order applied for other categories. No matter the number of categories which belong to a product, the number of categories need to be sorted, all order lists are saved and kept as defined!

First you can select the category for which you want to apply an order:
woocomerce-category-select
The order can be also set for other taxonomies defined like Product Tags, Tags etc, everything while keeping the sorts for the other places.

Re-order can be done using a simple drag and drop interface, then using Update to save.
woocomerce-product-sorting-interface

advanced-post-types-order-sort-interface-grid-view

A huge bonus for this plugin is the fact that it can be used also along with all other custom post types within your site (i.e. posts, pages, reviews, movies etc), practically you can sort the order for any content / post type / product.
The usage is very simple, once deployed the plugin will take care of the order update within the front side, no coding updates are necessarily.

The post WooCommerce – Sort Products which belong to multiple categories appeared first on Nsp Code.

]]>
https://www.nsp-code.com/woocommerce-sort-products-which-belong-to-multiple-categories/feed/ 5