Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Product Picker Row Content Rate Topic   - - - - -

 
  • natewallis
  • Senior Member
  • Members
  • Join Date: 11-Jan 13
  • 210 posts

Posted 18 February 2020 - 04:12 AM #1

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... 



 
  • Hungryweb
  • Senior Member
  • Authorized Reseller
  • Join Date: 10-Feb 12
  • 1257 posts

Posted 18 February 2020 - 01:41 PM #2

Yes, can be customised

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



 
  • natewallis
  • Senior Member
  • Members
  • Join Date: 11-Jan 13
  • 210 posts

Posted 18 February 2020 - 09:03 PM #3

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. 



 
  • natewallis
  • Senior Member
  • Members
  • Join Date: 11-Jan 13
  • 210 posts

Posted 18 February 2020 - 09:21 PM #4

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 :)



 
  • natewallis
  • Senior Member
  • Members
  • Join Date: 11-Jan 13
  • 210 posts

Posted 18 February 2020 - 09:41 PM #5

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... 



 
  • natewallis
  • Senior Member
  • Members
  • Join Date: 11-Jan 13
  • 210 posts

Posted 19 February 2020 - 02:10 AM #6

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?

<a data-ca-external-click-id="opener_picker_{$data_id}" class="cm-external-click btn">
	<i class="icon-plus"></i>
	{$but_text|default:__("add_products")}
</a>

<div class="table-wrapper">
	<table class="table table-middle">
		<thead>
			<tr>
				<th>SKU</th>
				<th width="20%">{__('bfa_resellers_pre_discount_increase_percentage')}</th>
				<th width="20%">{__('bfa_resellers_discount_percentage')}</th>
				<th width="20%">{__('bfa_resellers_actions')}</th>
			</tr>
		</thead>
		<tbody id="{$data_id}" class="{if !$item_ids}hidden {/if}cm-picker{if $display}-options{/if}">
			{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=""}
		</tbody>
		<tbody id="{$data_id}_no_item"{if $item_ids} class="hidden"{/if}>
			<tr class="no-items">
				<td colspan="{$colspan|default:"3"}"><p>{$no_item_text|default:__("no_items") nofilter}</p></td>
			</tr>
		</tbody>
	</table>
</div>

<div class="hidden">
	{if $extra_var}
	{assign var="extra_var" value=$extra_var|escape:url}
	{/if}
	{if !$no_container}<div class="buttons-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}</div>{/if}
	<div class="hidden" id="content_{$data_id}" title="{$but_text|default:__("add_products")}"></div>
</div>



 
  • natewallis
  • Senior Member
  • Members
  • Join Date: 11-Jan 13
  • 210 posts

Posted 26 February 2020 - 03:17 AM #7

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);