PHP code example of aligent / orocommerce-fees-bundle
1. Go to this page and download the library: Download aligent/orocommerce-fees-bundle library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
aligent / orocommerce-fees-bundle example snippets
namespace Acme\MyBundle\Fee\Provider;
use Aligent\FeesBundle\Fee\AbstractLineItemFeeProvider;
use Oro\Bundle\CheckoutBundle\Entity\Checkout;
class HandlingFeeProvider extends AbstractLineItemFeeProvider
{
const NAME = 'fees.handling_fee';
const TYPE = 'handling_fee';
const LABEL = 'acme.my_bundle.fees.handling_fee.label';
const SKU = 'HF001'; // Shouldn't be a real product
const AMOUNT = 10.00;
/**
* Get Fee name
* @return string
*/
public function getName(): string
{
return self::NAME;
}
/**
* Return label key
* @return string
*/
public function getLabel(): string
{
return $this->translator->trans(self::LABEL);
}
/**
* Return SKU of Fee
* @return null|string
*/
public function getSKU(): ?string
{
return self::SKU;
}
/**
* @param Checkout $checkout
* @return float|null
*/
public function getAmount(Checkout $checkout): ?float
{
return self::AMOUNT;
}
/**
* Is the fee Supported by this Entity?
* @param mixed $entity
* @return bool
*/
public function isSupported($entity): bool
{
return ($entity instanceof Checkout);
}
}
shell
php bin/console oro:platform:update --env=prod