Set price and cost to zero
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
-
- Posts: 44
- Joined: 05 Oct 2019, 06:42
Set price and cost to zero
Hi Aimeos,
I want to set price and delivery cost to 0 when the status of the order is set to Cancelled. This is what I have right now.
Now If I change the status to cancelled I want the "order.base.price" and "order.base.costs" to be set to zero. Please assist.
I want to set price and delivery cost to 0 when the status of the order is set to Cancelled. This is what I have right now.
Code: Select all
<?php
/**
* @license LGPLv3, https://opensource.org/licenses/LGPL-3.0
* @copyright Metaways Infosystems GmbH, 2011
* @copyright Aimeos (aimeos.org), 2015-2021
* @package MShop
* @subpackage Order
*/
namespace Aimeos\MShop\Order\Item\Base;
/**
* Default implementation of the shopping basket.
*
* @package MShop
* @subpackage Order
*/
class EbdaaOrderItemBase extends Standard
{
/**
* Returns a price item with amounts calculated for the products, costs, etc.
*
* @return \Aimeos\MShop\Price\Item\Iface Price item with price, costs and rebate the customer has to pay
*/
public function getPrice() : \Aimeos\MShop\Price\Item\Iface
{
if( $this->recalc )
{
$price = $this->price->clear();
foreach( $this->getServices() as $list )
{
foreach( $list as $service ) {
$price = $price->addItem( $service->getPrice() );
}
}
foreach( $this->getProducts() as $product ) {
// 0=deleted, 1=cancelled //removed 1 and rolled back
//as it was causing order.base.price to go 0 when
// we were choosing package ready
if( !in_array( $product->getStatus(), [0] ) ) {
$price = $price->addItem( $product->getPrice(),
$product->getQuantity() );
}
}
$this->price = $price;
$this->recalc = false;
}
return $this->price;
}
}
-
- Posts: 44
- Joined: 05 Oct 2019, 06:42
Re: Set price and cost to zero
Please assist here.
Re: Set price and cost to zero
Why do you want to set the price to zero? This makes usually no sense because the "cancelled" status removes the order price from being used and if the status is reverted back, you will have no price any more. That said, setting the price to zero is not recommended at all.
Back to your question:
In the order base item, there's no way to set the price based on the order payment status because this the status is only available in the order item (not order base item). Thus, you can only set the price in the order manager when the status change is saved.
Back to your question:
In the order base item, there's no way to set the price based on the order payment status because this the status is only available in the order item (not order base item). Thus, you can only set the price in the order manager when the status change is saved.
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