Source of file RefundHandler.php
Size: 1,900 Bytes - Last Modified: 2021-12-23T10:24:32+00:00
/var/www/docs.ssmods.com/process/src/src/bulkmanager/RefundHandler.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 | <?php namespace SilverCommerce\CatalogueAdmin\BulkManager; use SilverStripe\Control\HTTPResponse; use SilverStripe\Control\HTTPRequest; use SilverStripe\Core\Convert; use Colymba\BulkManager\BulkAction\Handler as GridFieldBulkActionHandler; /** * A {@link GridFieldBulkActionHandler} for bulk cancelling records * * @author i-lateral (http://www.i-lateral.com) * @package orders-admin */ class RefundHandler extends GridFieldBulkActionHandler { private static $url_segment = 'refund'; private static $allowed_actions = [ 'refund' ]; private static $url_handlers = [ "" => "refund" ]; /** * Front-end label for this handler's action * * @var string */ protected $label = 'Refund'; /** * Front-end icon path for this handler's action. * * @var string */ protected $icon = ''; /** * Whether this handler should be called via an XHR from the front-end * * @var boolean */ protected $xhr = true; /** * Set to true is this handler will destroy any data. * A warning and confirmation will be shown on the front-end. * * @var boolean */ protected $destructive = false; /** * Return i18n localized front-end label * * @return array */ public function getI18nLabel() { return _t('OrdersAdmin.Refund', $this->getLabel()); } public function refund(HTTPRequest $request) { $ids = []; foreach ($this->getRecords() as $record) { array_push($ids, $record->ID); $record->markRefunded(); $record->write(); } $response = new HTTPResponse(Convert::raw2json([ 'done' => true, 'records' => $ids ])); $response->addHeader('Content-Type', 'text/json'); return $response; } } |