Guest User

Untitled

a guest
Oct 20th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.33 KB | None | 0 0
  1. <?php if(Mage::getSingleton('customer/session')->isLoggedIn()){
  2. // Get group Id
  3. $groupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
  4. //Get customer Group name
  5. $group = Mage::getModel('customer/group')->load($groupId);
  6. echo $group->getCode();} ?>
  7.  
  8. protected function _createVatNumberValidationSoapClient($trace = false) {
  9. $options = array( 'soap_version'=>SOAP_1_1,
  10. 'exceptions'=>true,
  11. 'trace'=>1,
  12. 'cache_wsdl'=> WSDL_CACHE_NONE,
  13. 'user_agent' => 'Mozilla',
  14. 'proxy_port' => 80);
  15. return new SoapClient(self::VAT_VALIDATION_WSDL_URL, $options); }
  16.  
  17. {
  18. $vatClass = self::VAT_CLASS_DOMESTIC;
  19. } elseif ($isVatNumberValid) {
  20. $vatClass = self::VAT_CLASS_INTRA_UNION;
  21. } else {
  22. $vatClass = self::VAT_CLASS_INVALID;
  23. }
  24.  
  25. if (!$vatValidationResult->getRequestSuccess()) {
  26. $vatClass = self::VAT_CLASS_ERROR;
  27. }
  28.  
  29. {
  30. $vatClass = self::VAT_CLASS_DOMESTIC;
  31. $vatMessage='Sprzedaz krajowa';
  32. Mage::getSingleton('customer/session')->addNotice($customerCountryCode.$vatNumber .' '. $this->__($vatMessage));
  33. } elseif ($isVatNumberValid) {
  34. $vatClass = self::VAT_CLASS_INTRA_UNION;
  35. $vatMessage='Your VIES VAT Number has been verified. 0% tax rate applied.';
  36. Mage::getSingleton('customer/session')->addSuccess($customerCountryCode.$vatNumber .' '. $this->__($vatMessage));
  37. } else {
  38. $vatClass = self::VAT_CLASS_INVALID;
  39. $vatMessage='Your UE VAT Number is invalid! Please verify your account information and contact our customer support.';
  40. Mage::getSingleton('customer/session')->addError($customerCountryCode.$vatNumber .' '. $this->__($vatMessage));
  41. }
  42.  
  43. if (!$vatValidationResult->getRequestSuccess()) {
  44. $vatClass = self::VAT_CLASS_ERROR;
  45. $vatMessage='There was an error during validation of your UE VAT Number. Probably the VIES verification services are currently unavailable. Normal tax rate has been applied.';
  46. Mage::getSingleton('customer/session')->addError($customerCountryCode.$vatNumber .' '. $this->__($vatMessage));
  47. }
  48. return $vatClass;
  49. }
  50.  
  51. <?php echo Mage::getSingleton('customer/session')->getMessages()->count(); ?>
  52.  
  53. <?php if($this->getMessagesBlock()->getMessageCollection()->count()): ?>
  54. <?php foreach($this->getMessagesBlock()->getMessageCollection()->getItems() as $message): ?>
  55. <div class="alert alert-<?php echo $message->getType()?> fade in">
  56. <a class="close" data-dismiss="alert">×</a>
  57. <h4 class="alert-heading">
  58. <?php echo $this->__('Notice!') ?></h4>
  59. <?php echo $message->getCode()?>
  60. </div>
  61. <?php endforeach;?>
  62. <?php endif; ?>
  63. <?php $this->getMessagesBlock()->getMessageCollection()->clear(); ?>
  64.  
  65. if (Mage::getSingleton('customer/session')->isLoggedIn()){
  66. $customer = $observer->getEvent()->getCustomer();
  67. if( // vat id condition):
  68. $customerHelper = Mage::helper('customer');
  69. $defaultGroupId = $customerHelper->getDefaultCustomerGroupId($customer->getStore());
  70. if (!$customer->getDisableAutoGroupChange() && $customer->getGroupId() != $defaultGroupId) {
  71. $customer->setGroupId($defaultGroupId);
  72. $customer->save();
  73. }
  74. endif;
  75. }
Add Comment
Please, Sign In to add comment