Listen nach Preisnachlass filtern

Damit man Produkte mittels Preisnachlass in einer Liste filtern kann, kann man diesen Filter nutzen. Es ergänzt die Liste um ein weiteres Feld "Minimum percentage".

Ist dieses Feld befüllt, wird die Liste nach dem Laden von der API nochmals gefiltert. Es werden damit nur Produkte angezeigt welche auch wirklich Minimum Percentage haben.

function atkp_list_modify_productlist_callback( $products, $list_id ) {	
	$minpercentage = ATKPTools::get_post_setting( $list_id, ATKP_LIST_POSTTYPE . '_minpercentage' );
	
	if($minpercentage == '' || $minpercentage == 0)
		return $products;
	
	$products_filtered = array();

	foreach($products as $product_arr) {
		if($product_arr['type'] != 'product') {
			$products_filtered[] = $product_arr;
			continue;
		}

		if(floatval($product_arr['value']->percentagesaved) > $minpercentage) {
			$products_filtered[] = $product_arr;
		}
	}
	return $products_filtered ;
}


add_filter( 'atkp_list_modify_productlist', 'atkp_list_modify_productlist_callback', 10,2);




function atkp_list_after_fields_callback($list_id) {
	$list_id = get_the_ID();
	?>
<tr>
            <th scope="row">
                <label for="">
					<?php _e( 'Minimum percentage', ATKP_PLUGIN_PREFIX ) ?>:
                </label>
            </th>
            <td>
                <input type="number" style="width:100%" id="<?php echo ATKP_LIST_POSTTYPE . '_minpercentage' ?>"
                       name="<?php echo ATKP_LIST_POSTTYPE . '_minpercentage' ?>"
                       value="<?php echo ATKPTools::get_post_setting($list_id, ATKP_LIST_POSTTYPE . '_minpercentage', true ); ?>">

            </td>
        </tr>
	<?php
}

add_action('atkp_list_after_fields', 'atkp_list_after_fields_callback', 10, 1);


function atkp_list_save_fields_callback($list_id) {
	$minpercentage  = ATKPTools::get_post_parameter( ATKP_LIST_POSTTYPE . '_minpercentage', 'int' );
	
	ATKPTools::set_post_setting( $list_id, ATKP_LIST_POSTTYPE . '_minpercentage', $minpercentage );
}

add_action('atkp_list_save_fields', 'atkp_list_save_fields_callback', 10, 1);

Füge dieses Snippet einfach in deine functions.php oder in ein Snippets-Plugin ein.

Man kann die Vorlagen nicht löschen, allerdings kann man die Vorlagen einfach via Hook ausblenden.

Mit diesem Hook werden nur benutzerdefinierte Vorlagen angezeigt und so kann man dem Redakteur das finden einer Vorlage einfacher gestalten.

function atkp__modify_template_list(  $templates, $add_systemdir, $is_searchform ) {
 
     $newtemplates = array();
     
     foreach($templates as $template => $val) {
          if(is_numeric($template))
                $newtemplates[$template] = $val;
     }
     
    return $newtemplates;
}
add_filter( 'atkp_template_list', 'atkp__modify_template_list', 10, 3);

Hallo,

die findest du hier: https://www.affiliate-toolkit.com/downloads/template-pack/

VG Christof

for removing the VAT text in a template you must delete this line of text:

So copy the systemtemplate you want to use and change the line I marked green in the previous mail:

 <span class="atkp-priceinfo">{{$formatter->get_priceinfotext($product)}}</span>

You can delete it or you can also change it to:

 <span class="atkp-priceinfo">This link is an affiliate link </span>

For changing the currency symbol in dollar you need to change this in your amazon shop (wp backend):

and you can also change it to custom symbol. Set prefix and suffix: 

Bitte Lizenz einmal raus löschen und speichern. Danach Lizenz einfügen und noch mal speichern.

linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram