Help for integrating the Laravel package
Forum rules: Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
#3305 by jossnaz
30 Aug 2016, 00:46
i am on 2016.07.2


when running my tax by state plugin i get when accessing the basket:

"Please have a look at the prices of the products in your basket"
"The price of at least one product has changed in the meantime and it was updated automatically"

what is the correct way to avoid these warnings / errors / infos when adjusting the tax rate for a basket depending on the state the user chose to be in.


i can just suppress them in the pages, but i doubt that is the correct way.


what I currently do is:

in
ff-laravel/ext/cmc-usa-salestax-by-state/client/html/templates/common/summary/detail-body-default.php



Code: Select allif($errors){
  foreach($errors as $key_pe => &$pe){ //prodcuterror
    if(is_array($pe)){
      foreach($pe as $key_se => $single_error){
        if($single_error == 'price.changed'){
          unset($pe[$key_se]);
        }
      }
    }
  }
}



furthermore in:

ff-laravel/resources/views/cmc/aimeos/basket/cmc_basket_body.php

this file replaces the file:

Code: Select all  'client' => array(
    'html' => array(
      'basket' => array(
        'standard' => array(
          'standard' => array(
            'template-body' =>
              __DIR__ . '/../resources/views/cmc/aimeos/basket/cmc_basket_body.php'
          )
        )
      ),


it has these new snippets:

Code: Select all$checkout = true;
/** @var \Aimeos\MShop\Order\Item\Base\Standard $myBasket */
$myBasket = $this->standardBasket;
try {
  $myAddress = $myBasket->getAddress($domain = \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT);
} catch (\Exception $e) {
  $myAddress = null;
}
try {
  $myBasket->check(\Aimeos\MShop\Order\Item\Base\Base::PARTS_PRODUCT);
} catch (Exception $e) {
  if ($e->getMessage() == 'Please have a look at the prices of the products in your basket') {
    $checkout = true;
  } else {
    $checkout = false;
  }
}
if ($myAddress == null) { ?>
  <style type="text/css">
    .total {
      display: none;
    }

    .tax {
      display: none;
    }
  </style>
<?php }



and:

Code: Select all<?php
if (isset($this->standardErrorList)) {

  $temp_list = $this->standardErrorList;
  foreach ((array)$this->standardErrorList as $key => $errmsg) : ?>
    <?php if ($errmsg === 'Please have a look at the prices of the products in your basket' || $errmsg === 'The price of at least one product has changed in the meantime and it was updated automatically') {
      unset($temp_list[$key]);
    }

    ?>
  <?php endforeach;
  $this->standardErrorList = $temp_list;
  if (count($this->standardErrorList) == 0) {
    unset($this->standardErrorList);
  }
}
?>


that is, just remove the final error products as i don't want them to appear each time a user merely access the basket and my plugin was executed.