Add custom "Option" to Coupon - how to retrieve in checkout?
Forum rules
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Re: Add custom "Option" to Coupon - how to retrieve in checkout?
Thats the whole point of that option, we use moodle as elearning tool and there is a rest api we use to pass the course on so if i use the options, i'll just add another course with the api.
So, how would i get the options?
So, how would i get the options?
Re: Add custom "Option" to Coupon - how to retrieve in checkout?
You can get the config with:
$couponItem->getConfig()
// or
$couponItem->getConfigValue( 'key' )
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Add custom "Option" to Coupon - how to retrieve in checkout?
In which context is that supposed to work?
I retrieve the Coupon with
and loop through them with foreach, your code throws an exception?
I retrieve the Coupon with
Code: Select all
$coupons = $this->summaryBasket->getCoupons();
Re: Add custom "Option" to Coupon - how to retrieve in checkout?
Only for the coupon item, the order coupon item doesn't have that methods.
You have to get the coupon item for the code first:
You have to get the coupon item for the code first:
Code: Select all
$manager = \Aimeos\MShop::create( $this->getContext(), 'coupon' );
$search = $manager->createSearch();
$search->setConditions( $search->compare( '==', 'coupon.coupon.code', array_keys( $coupons ) ) );
$couponItems = $manager->searchItems( $search );
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Add custom "Option" to Coupon - how to retrieve in checkout?
Throws an exception:
Class "\Aimeos\MW\View\Helper\GetContext\Standard" not available
I mean, it seriously cant be that hard to access that option....
Class "\Aimeos\MW\View\Helper\GetContext\Standard" not available
I mean, it seriously cant be that hard to access that option....
Re: Add custom "Option" to Coupon - how to retrieve in checkout?
Okay, so I've added a decorator. Everything fine, just how do i access the coupon code? Whatever i try to retrieve with $view->get throws an error or null....
Decorator is included as:
plugin.tx_aimeos.settings.client.html.checkout.confirm.decorators.global{
0 = CouponCourse
}
Code is
Decorator is included as:
plugin.tx_aimeos.settings.client.html.checkout.confirm.decorators.global{
0 = CouponCourse
}
Code is
Code: Select all
public function addData( \Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null )
{
$view = parent::addData( $view, $tags, $expire );
// access already added data
$products = $view->get( 'listsItems', [] );
var_dump($products);
// fetch some items from the database
$view->couponCourseCodes = '';
return $view;
}
Re: Add custom "Option" to Coupon - how to retrieve in checkout?
Alright.... fixed that too now. Another error popped up...
Here is my Decorator right now...
EDIT: Okay, seemingly its not coupon.coupon.code but coupon.code.code, after some digging into the core, i found that and it seems to work.
Code: Select all
2019-09-12 12:00:37 client/html 4 df61f077a8341b8da5fd7778fa060c3b Invalid name "coupon.coupon.code
Code: Select all
public function addData( \Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null )
{
$view = parent::addData( $view, $tags, $expire );
// access already added data
$coupons = $view->summaryBasket->getCoupons();
$manager = \Aimeos\MShop::create( $this->getContext(), 'coupon' );
$search = $manager->createSearch();
$search->setConditions( $search->compare( '==', 'coupon.coupon.code', array_keys( $coupons ) ) );
$couponItems = $manager->searchItems( $search );
// fetch some items from the database
$view->couponCourseCodes = '';
return $view;
}