Jump to content

Edit History

seb776

seb776

Hello,

I want to add a information on cart page.
I'd like to display if a product is payed or offered (discount free gift).

So, I added the information on the template .

{$product.gift}

 

But the property is not defined.
 

So I added, the proper property in ProductLazyArray.php

/**
* @arrayAccess
* @return string */
public function getGift()
{
   return 'gift';
}

 

if I dump the data after the AbstractLazyArray constructor, the gift property is here. ok.

But when accessing it, it is not in the index, despite my code editor does not find any other modification of $this->arrayAccessList .

So {$product.gift} is always empty ...

What am I missing ??

(I know changing core files is not a good practice, how should I do it correctly ?)

seb776

seb776

Hello,

I want to add a information on cart page.
I'd like to display if a product is payed or offered (discount free gift).

So, I added the information on the template .

```smarty
{$product.gift}
```

But the property is not defined.
 

So I added, the proper property in

```php
/**
* @arrayAccess
* @return string */
public function getGift()
{
   return 'gift';
}
```

if I dump the data after the AbstractLazyArray constructor, the gift property is here. ok.

But when accessing it, it is not in the index, despite my code editor does not find any other modification of $this->arrayAccessList .

So {$product.gift} is always empty ...

What am I missing ??

(I know changing core files is not a good practice, how should I do it correctly ?)

×
×
  • Create New...