Product Picker Row Content

Hi,

I am using this template

backend/templates/pickers/products/picker.tpl

Is it possible to customise the row content for picked products after the picker is closed?

Thanks...

Yes, can be customised

please share more details about what product picker type and what extra columns do you need

Ok,

I am writing an addon that lets my boss manage his resellers and generates pdf pricelists for his resellers.

For each reseller he can specify a discount percentage

Some resellers also get special discounts on particular products, so he wants to have the ability to override the default percentage for products of his choosing.

I was planning on using the product picker to allow him to add products and once the products have been added, each row would have an extra column that contains an input field which can be processed when the page is POST'ed...

So far, the default usage of the product picker when imported into my own template is to just have the product SKU and the ability to add or remove it from the list.

This is how I am including the template:

{include file="pickers/products/picker.tpl" input_name="resller_data[overrides]" data_id="reseller_overrides" item_ids=$supplier.products type="links"}

I see that if I use "table" as the type of picker, I get access to hooks that will let me override the row for my particular view... is this what you are suggesting?

{include file="pickers/products/picker.tpl" input_name="resller_data[overrides]" data_id="reseller_overrides" item_ids=$supplier.products type="table"}

The only issue with that is that the product picker then has product options selectable, but I just want the product to be selected, I am not interested in the options. But using type "links" does not give me access to any hooks to override the table content.

Maybe I have to write my own picker TPL file. I was hoping to use something that is directly included with CS-CART so that I avoid any maintenance in the future... so I will hold out hope until I hear from someone who might know more than I have discovered :)

I see there are a few options like "links" and "picker_view" which I was hoping would allow me to pass my own template for rendering, but no such luck. Will keep playing with the options and see what I can stumble upon.

The only way I can see to have full control is to define my own table and include pickers/products/js.tpl with the options I require...

Something like this - what do you think? I basically ripped this from `backend/templates/pickers/products/picker.tpl` and tweaked a few values so that the picker didn't display product options and the amount column option is not displayed.... would this be ok?


	
	{$but_text|default:__("add_products")}

{if $item_ids} {foreach from=$item_ids item="product" key="product_id"} {if $product.product} {assign var="product_name" value=$product.product} {else} {assign var="product_name" value=$product.product_id|fn_get_product_name|default:__("deleted_product")} {/if} {include file="pickers/products/js.tpl" product=$product_name root_id=$data_id delete_id=$product_id input_name="`$input_name`[`$product_id`]" amount_input="hidden" type="options" options=$smarty.capture.product_options options_array=$product.product_options product_id=$product.product_id product_info=$product} {/foreach} {/if} {include file="pickers/products/js.tpl" clone=true product="`$ldelim`product`$rdelim`" root_id=$data_id delete_id="`$ldelim`delete_id`$rdelim`" input_name="`$input_name`[`$ldelim`product_id`$rdelim`]" amount_input="hidden" type="options" options="`$ldelim`options`$rdelim`" product_id=""}
SKU {__('bfa_resellers_pre_discount_increase_percentage')} {__('bfa_resellers_discount_percentage')} {__('bfa_resellers_actions')}

{$no_item_text|default:__("no_items") nofilter}

{if $extra_var} {assign var="extra_var" value=$extra_var|escape:url} {/if} {if !$no_container}
{/if}{if $picker_view}[{/if} {include file="buttons/button.tpl" but_id="opener_picker_`$data_id`" but_href="products.picker?display=`$display`&company_id=`$company_id`&company_ids=`$company_ids`&picker_for=`$picker_for`&extra=`$extra_var`&checkbox_name=`$checkbox_name`&aoc=`$aoc`&data_id=`$data_id`&is_order_management=`$is_order_management`"|fn_url but_text=$but_text|default:__("add_products") but_role="add" but_target_id="content_`$data_id`" but_meta="cm-dialog-opener"} {if $picker_view}]{/if}{if !$no_container}
{/if}

I have pretty much got this working and have discovered how the cscart picker.js file (/js/tygh/picker.js) does template injection when cloning picker rows.

But what I don't get is why it uses crc32 on the frnot end for the selected product id (about line 126).

This product_id is then injected using str_replace about line 154... but how am I meant to determine what the selected product id was on the backend when the form is submitted?

var product_id = $.crc32(options_combination);

Hi natewallis, did you figure this out? I'm looking for a way to customize the required_products addon to add a extra column so would be very grateful if you could share some of your work ;)

Hi - I did get it working... I'll go through my notes tommorow..

Hi, thanks, please let me know