0

I am trying to create a note on a PDF invoice which is only shown for a specific customer group. I use Magento 1.9.2.4 with the Firegento PDF Extension.

My code so far is:

public function addTaxNotes(Varien_Event_Observer $observer)
    {
     $groupId = Mage::getSingleton('customer/session')->getCustomerGroupId(); 
        if($groupId = 6) {
             $page = $observer->getPage();
        $page->drawText('Tax-exempt intra-Community supply according 4 Nr.1b UstG i.V. § 6aUStG ', 0, 120, 'UTF-8');
        return $this;
        }
        }

My problem is, that the "if" function doesn`t work. The note is shown to all customer no matter which customer group they belong to. Can somebody help me?

1

Your comparison is using a "=" instead of a "==" operator:

if($groupId = 6) {

Change to

if($groupId == 6) {
  • Hi, thanks but this won`t solve the problem unfortunaly. If I change it to "==" the text is not shown at all. It seems that somehow the GroupId is not called correctly. Using for example the Country Code instead of the Customer Group it works perfectly. – McZoid Jul 6 '17 at 7:34
0

The problem is in if ($groupId = 6) { you are assign the value to groupid. not check. Please change and check if ($groupId == 6) {

0

Please use below code.

$customer = Mage::getSingleton('customer/session')->getCustomer();
$groupId = $customer->getGroupId();
if($groupId == 6) {

Hope it will work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.