Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AjaxDelete.php
Go to the documentation of this file.
1 <?php
8 
10 
12 {
18  public function execute()
19  {
20  $rateId = (int)$this->getRequest()->getParam('tax_calculation_rate_id');
21  try {
22  $this->_taxRateRepository->deleteById($rateId);
23  $responseContent = ['success' => true, 'error_message' => ''];
24  } catch (\Magento\Framework\Exception\LocalizedException $e) {
25  $responseContent = ['success' => false, 'error_message' => $e->getMessage()];
26  } catch (\Exception $e) {
27  $responseContent = [
28  'success' => false,
29  'error_message' => __('We can\'t delete this tax rate right now.')
30  ];
31  }
32 
34  $resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON);
35  $resultJson->setData($responseContent);
36  return $resultJson;
37  }
38 }
__()
Definition: __.php:13