{$has_at_least_one_combination = false} {$default_product_sale_element_id = 0} {loop name="product.sales.elements.test" type="product_sale_elements" product=$product_id currency=$edit_currency_id backend_context="1"} {loop name="product.combinations" type="attribute_combination" product_sale_elements="$ID"} {$has_at_least_one_combination = true} {/loop} {elseloop rel="product.combinations"} {$default_product_sale_element_id = $ID} {/elseloop} {/loop} {if $has_at_least_one_combination == false} {form name="thelia.admin.product_default_sale_element.update"} {include file = "includes/inner-form-toolbar.html" hide_submit_buttons = false show_currencies = true page_url = "{url path='/admin/products/update' product_id=$ID}" close_url = "{url path='/admin/categories' category_id=$DEFAULT_CATEGORY}" } {* Be sure to get the product ID and current tab, even if the form could not be validated *} {form_hidden_fields} {form_field field='product_id'} {/form_field} {form_field field='product_sale_element_id'} {/form_field} {form_field field='isdefault'} {/form_field} {form_field field='reference'} {/form_field} {form_field field='success_url'} {/form_field} {loop type="currency" name="product-currency" id=$edit_currency_id backend_context="1"} {$currency_symbol = $SYMBOL} {$currency_name = $NAME} {form_field field='currency'} {/form_field} {$current_currency_is_default = $IS_DEFAULT} {/loop} {if $form_error}
{$form_error_message}
{/if}
{form_field field='tax_rule'}
{$label} :
{/form_field}

{intl l='Pricing'}

{intl l="The default pricing is used when no combination is defined."}

{* -- Pricing ------------------------------------------------------- *}

{intl l='Pricing'}

{form_field field='use_exchange_rate'} {if $current_currency_is_default} {$show_pricing_fields = true} {else}
{$label}
{$show_pricing_fields = ($value == 0)} {/if} {/form_field} {form_field field='price'}
{$label} :
{$currency_symbol}
{/form_field} {form_field field='price_with_tax'}
{intl l="Product price including taxes"} :
{$currency_symbol}
{/form_field} {hook name="product.details-pricing-form" location="product_details_pricing_form" }
{* -- Détails -------------------------------------------------- *}

{intl l='Stock'}

{form_field field='ean_code'}
{$label} :
{/form_field} {form_field field='weight'}
{$label} :
{intl l="Kg"}
{/form_field} {form_field field='quantity'}
{$label} :
{/form_field} {hook name="product.details-details-form" location="product_details_details_form" }
{* -- Promotion ------------------------------------------------- *}

{intl l='Promotion'}

{form_field field='sale_price'}
{$label} :
{$currency_symbol}
{/form_field} {form_field field='sale_price_with_tax'}
{$label} :
{$currency_symbol}
{/form_field} {form_field field='onsale'}
{$label}
{/form_field} {form_field field='isnew'}
{$label}
{/form_field} {hook name="product.details-promotion-form" location="product_details_promotion_form" }
{/form} {/if} {* -- Attribute combinations -------------------------------------------- *} {if $has_at_least_one_combination} {form name="thelia.admin.product_sale_element.update"}
{include file = "includes/inner-form-toolbar.html" hide_submit_buttons = false show_currencies = true page_url = "{url path='/admin/products/update' product_id=$ID}" close_url = "{url path='/admin/categories' category_id=$DEFAULT_CATEGORY}" } {* Be sure to get the product ID and current tab, even if the form could not be validated *} {form_hidden_fields} {form_field field='product_id'} {/form_field} {form_field field='success_url'} {/form_field} {if $form_error}
{$form_error_message}
{/if} {loop type="currency" name="get-currency-symbol" id=$edit_currency_id backend_context="1"} {$currency_symbol = $SYMBOL} {$current_currency_is_default = $IS_DEFAULT} {form_field field='currency'} {/form_field} {/loop}
{form_field field='tax_rule'}
{$label} :
{/form_field}
{form_field field='use_exchange_rate'} {if $current_currency_is_default} {$show_pricing_fields = true} {else}
{$label}
{$show_pricing_fields = ($value == 0)} {/if} {/form_field}
{hook name="product.before-combinations" location="product_before_combinations" }

{intl l='Attribute Combinations'} {hook name="product.combinations-list-caption" location="product_combinations_list_caption" } {loop type="auth" name="can_create" role="ADMIN" resource="admin.product" access="UPDATE"} {intl l='Combination builder'} {/loop}
{intl l='Reference'} | {intl l='EAN Code'} | {intl l='Stock'} | {intl l='Price (%currency) w/o taxes' currency={$currency_symbol}} | {intl l='Price (%currency) w/ taxes' currency={$currency_symbol}} | {intl l='Weight (Kg)'} | {intl l='Default'} | {intl l='Sale'} | {intl l='New'} | {intl l='Sale price (%currency) w/o taxes' currency={$currency_symbol}} | {intl l='Sale price (%currency) w/ taxes' currency={$currency_symbol}}
--- | --- | --- | --- | --- | --- | --- | --- | --- | --- | ---
{* Get number of PSE defined, assume the form have the same number of values for each fields *} {form_field field='product_sale_element_id' value_key=0} {$pse_count = $total_value_count} {/form_field} {for $idx = 0 to $total_value_count-1}
{form_field field='product_sale_element_id' value_key=$idx} {$current_pse_id = $value} {/form_field} {if $VIRTUAL} {/if} {assign var='combination_list' value=array()} {loop name="product.sales.elements.combinations" type="attribute_combination" product_sale_elements=$current_pse_id backend_context="1" order="manual"} {$combination_list[$ATTRIBUTE_TITLE][] = $ATTRIBUTE_AVAILABILITY_TITLE} {/loop} {format_array_2d values=$combination_list} | ID: {$current_pse_id}
{form_field field='reference' value_key=$idx} {/form_field} {form_field field='ean_code' value_key=$idx} | {/form_field} {form_field field='quantity' value_key=$idx} | {/form_field} {form_field field='price' value_key=$idx} | {/form_field} {form_field field='price_with_tax' value_key=$idx} | {/form_field} {form_field field='weight' value_key=$idx} | {/form_field} {form_field field='default_pse'} | {/form_field} {form_field field='onsale' value_key=$idx} | {/form_field} {form_field field='isnew' value_key=$idx} | {/form_field} {form_field field='sale_price' value_key=$idx} | {/form_field} {form_field field='sale_price_with_tax' value_key=$idx} | {/form_field}
{hook name="product.combinations-row" pse=$current_pse_id idx=$idx} {/for}

{hook name="product.after-combinations" location="product_after_combinations" } {include file = "includes/inner-form-toolbar.html" hide_submit_buttons = false hide_flags = true page_url = "{url path='/admin/products/update' product_id=$ID}" close_url = "{url path='/admin/categories' category_id=$DEFAULT_CATEGORY}" }
{/form} {/if} {if $has_at_least_one_combination == false}

{intl l='Attribute Combinations'}

{intl l='This product has no combination. The default price is used. Click here to create a new combination.' url='#combination_creation_dialog' }

{intl l='You may also quickly create combinations from products attributes using the Combination Builder.' url='#combination_builder_dialog' }

{/if}
{* PSE / Image-Document combination modal *}

####

{* -- Adding a new combination ------------------------------------------------- *} {* Capture the dialog body, to pass it to the generic dialog *} {capture "combination_creation_dialog"}
{intl l="Attribute"} :
{intl l='Select an attribute and click (+) to view available values'}
{* {intl l="Attribute values"} : *}
{intl l='Select a value click (+) to add it to the combination'}
{intl l="No available value for this attribute"}
{intl l='To remove a value from the combination, select it and click "remove"'}
{/capture} {include file = "includes/generic-create-dialog.html" dialog_id = "combination_creation_dialog" dialog_title = {intl l="Create a new combination"} dialog_body = {$smarty.capture.combination_creation_dialog nofilter} dialog_ok_label = {intl l="Create this combination"} form_action = {url path='/admin/product/combination/add'} form_enctype = '' form_error_message = '' ok_button_id = "combination_creation_dialog_ok" } {* -- Delete combination confirmation dialog ----------------------------------- *} {capture "combination_delete_dialog"} {hook name="product.combination-delete-form" location="product_combination_delete_form" } {/capture} {include file = "includes/generic-confirm-dialog.html" dialog_id = "combination_delete_dialog" dialog_title = {intl l="Delete a combination"} dialog_message = {intl l="Do you really want to delete this combination ?"} form_action = {url path='/admin/product/combination/delete'} form_content = {$smarty.capture.combination_delete_dialog nofilter} } {* -- Combination builder dialog -------------------------------------------- *} {* Capture the dialog body, to pass it to the generic dialog *} {form name="thelia.admin.product_combination.build"} {capture "combination_builder_dialog"} {* Be sure to get the product ID and current tab, even if the form could not be validated *} {form_hidden_fields} {form_field field='product_id'} {/form_field} {if $form_error}
{$form_error_message}
{/if} {loop type="currency" name="get-currency-symbol" id=$edit_currency_id backend_context="1"} {$currency_symbol = $SYMBOL} {form_field field='currency'} {/form_field} {/loop} {form_field field='success_url'} {/form_field}
{intl l='Select attribute values to combine. You may enter a default value for some of the fields of the generated combinations.'}

{$index = 0} {loop name="product-attributes" type="attribute" order="manual" product=$product_id backend_context="1" lang=$edit_language_id} {ifloop rel="product-attributes-av"}
- {$TITLE}
  {loop name="product-attributes-av" type="attribute_availability" attribute=$ID order="manual" backend_context="1" lang=$edit_language_id}
  - {form_field field='attribute_av' value_key=$index} {$TITLE} {/form_field}
  {$index = $index + 1} {/loop}
{/ifloop} {/loop}

{loop type="product_sale_elements" name="product_sale_elements_combination_form" product=$product_id default="yes" limit=1 backend_context=1}
{form_field field='price'}
{$label} :
{$currency_symbol}
{/form_field}
{intl l="Product price including taxes"} :
{$currency_symbol}
{form_field field='reference'}
{$label} :
{/form_field} {form_field field='ean_code'}
{$label} :
{/form_field}
{form_field field='weight'}
{$label} :
{intl l="Kg"}
{/form_field}
{form_field field='quantity'}
{intl l='Stock'} :
{/form_field}
{form_field field='sale_price'}
{$label} :
{$currency_symbol}
{/form_field} {form_field field='onsale'}
{$label}
{/form_field} {form_field field='isnew'}
{$label}
{/form_field} {/loop}
{intl l='0 combinations'}
{/capture} {include file = "includes/generic-create-dialog.html" dialog_id = "combination_builder_dialog" dialog_title = {intl l="Create combinations"} dialog_body = {$smarty.capture.combination_builder_dialog nofilter} dialog_ok_label = {intl l="Create combinations"} form_action = {url path='/admin/product/combination/build'} form_enctype = {form_enctype} form_error_message = '' ok_button_id = "combination_builder_dialog_ok" } {/form}