Prestashop 1.7 - array() categories in order-confirmation.tpl

350 Views Asked by At

I would like to add conditions for specific category in order-confirmation.tpl

I can show only the default category like this :

{if $product.id_category_default == 374} Yippee-ki-yay {/if}

But i must to do with associated categories like this :

{if in_array(374,Product::getProductCategories($product.id|intval))}Yippee-ki-yay{/if}

Thx for everything

1

There are 1 best solutions below

2
KoreLewi On

Generate a new module and implement the orderConfirmation hook:

  public function hookOrderConfirmation($params)
    {
        $order = $params['order'];
        $products = $order->getCartProducts();
        $flag = false;
        foreach($products as $product){
            if(in_array(374, Product::getProductCategories($product->id))) {
                $flag = true;
            }
        }
         $this->smarty->assign(array(
                'myCustomFlag' => $flag,
         ));
    }

And you can use the 'myCustomFlag' variable in the order-confirmation.tpl

{if $myCustomFlag} Yippee-ki-yay {/if}