开发者

Magento: Add customer group to pdf packing slip

I am tr开发者_如何学JAVAying to add the customer's group to the pdf packing slips. I am assuming this should be done in Sales/Model/Order/Pdf/Abstract.php, but what do I put where?

Thanks


Ok, here is what I did. I put the following code - that I wrote:

/* Add Customer Type to Invoice */
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
$readresult=$write->query("select customer_id from `sales_order` where increment_id = ".$order->getIncrementId()." limit 0,1;");
$row = $readresult->fetch();
$customerId = $row['customer_id'];
$myRoleId = 1;

if (!empty($customerId)) {
    $write = Mage::getSingleton('core/resource')->getConnection('core_write');
    $readresult=$write->query("select group_id from `customer_entity` where entity_id = ".$customerId." limit 0,1;");
    $row = $readresult->fetch();
    $myRoleId = $row['group_id'];
}

switch ($myRoleId){
case 2: $groupTitle = 'Wholesaler Invoice';
  break;
case 3: $groupTitle = 'Retailer Invoice';
  break;
case 4: $groupTitle = 'Dealer Invoice';
  break;
default: $groupTitle = 'Customer Invoice';
  break;
}

$page->drawText($groupTitle, 480, 780, 'UTF-8');    
/* End add Customer Type */     

Immediately after this block of code that already existed:

/* Add head */
$this->insertOrder($page, $order, Mage::getStoreConfigFlag(self::XML_PATH_SALES_PDF_INVOICE_PUT_ORDER_ID, $order->getStoreId()));

$page->setFillColor(new Zend_Pdf_Color_GrayScale(1));
$this->_setFontRegular($page);
$page->drawText(Mage::helper('sales')->__('Invoice # ') . $invoice->getIncrementId(), 35, 780, 'UTF-8');

In the app\code\local\Mage\Sales\Model\Order\Pdf\Invoice.php file


If you have $order available, like in Abstract.php, you can use the following code to get the customer group ID and name.

$customerGroupId = $order->getCustomerGroupId();
$groupname = Mage::getModel('customer/group')->load($customerGroupId)->getCustomerGroupCode();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜