Skip to content

Commit

Permalink
fix(earning-suggestion): multiple category selection mess up with ear…
Browse files Browse the repository at this point in the history
…ning suggesting is fixed (#252)

* fix(earning-suggestion): multiple category selection mess up with earning suggesting is fixed

* refactor(taxonomy-walker): remove remove unwanted code and make var to public

* refector(earning-suggestion): remove empty string from constructor
  • Loading branch information
saimonh3 authored and sabbir1991 committed May 15, 2018
1 parent 0fa41d8 commit b62f1c9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
22 changes: 17 additions & 5 deletions lib/class.taxonomy-walker.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,32 @@ class DokanTaxonomyWalker extends Walker{
* @see Walker::$tree_type
* @var string
*/
var $tree_type = 'category';
public $tree_type = 'category';

/**
* @see Walker::$db_fields
* @var array
*/
var $db_fields = array('parent' => 'parent', 'id' => 'term_id');
public $db_fields = array('parent' => 'parent', 'id' => 'term_id');

private $post_id = '';

public function __construct( $post_id = '' ) {
// fetch the list of term ids for the given post
$this->post_id = $post_id;
}


function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
$pad = str_repeat( ' ', $depth * 3 );

$commission_val = dokan_get_seller_percentage( dokan_get_current_user_id(), $this->post_id, $category->term_id );
$commission_type = dokan_get_commission_type( dokan_get_current_user_id(), $this->post_id, $category->term_id );

$pad = str_repeat( ' ', $depth * 3 );
$cat_name = apply_filters( 'list_cats', $category->name, $category );
$output .= "\t<option class=\"level-$depth\" value=\"" . $category->term_id . "\"";

$output .= "\<option class=\"level-$depth\" value=\"" . $category->term_id . "\"";
$output .= ' data-commission="' . $commission_val . '" data-commission_type="' . $commission_type . '"';
if ( in_array( $category->term_id, $args['selected'] ) )
$output .= ' selected="selected"';
$output .= '>';
Expand All @@ -32,4 +44,4 @@ function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
$output .= '&nbsp;&nbsp;(' . $category->count . ')';
$output .= "</option>\n";
}
}
}
4 changes: 2 additions & 2 deletions templates/products/new-product-single.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@
'exclude' => '',
'selected' => $term,
'echo' => 0,
'walker' => new DokanTaxonomyWalker()
'walker' => new DokanTaxonomyWalker( $post_id )
) ) );

echo str_replace( '<select', '<select data-placeholder="'.__( 'Select product category', 'dokan-lite' ).'" multiple="multiple" ', $drop_down_category );
Expand All @@ -334,7 +334,7 @@
'exclude' => '',
'selected' => $selected,
'echo' => 0,
'walker' => new DokanTaxonomyWalker()
'walker' => new DokanTaxonomyWalker( $post_id )
) );

echo str_replace( '<select', '<select data-placeholder="'.__( 'Select product tags', 'dokan-lite' ).'" multiple="multiple" ', $drop_down_tags );
Expand Down

0 comments on commit b62f1c9

Please sign in to comment.