在处理文章段落的时候会出现文章段落出去了,不换行,如果用overflow,加上滑动条,是不实际的,我们希望的是自动换行,css其实是有这个属性了,查了一番找到了就是如下的css属性:
word-wrap: break-word;
在p标签的上层加一个div,然后css属性加上这个就可以了!
在处理文章段落的时候会出现文章段落出去了,不换行,如果用overflow,加上滑动条,是不实际的,我们希望的是自动换行,css其实是有这个属性了,查了一番找到了就是如下的css属性:
word-wrap: break-word;
在p标签的上层加一个div,然后css属性加上这个就可以了!
Here, I will show you how you can get information about all items in your Magento Shopping Cart. You will see how you can :-
- Get products id, name, price, quantity, etc. present in your cart.
- Get number of items in cart and total quantity in cart.
- Get base total price and grand total price of items in cart.
Get all items information in cart
// $items = Mage::getModel('checkout/cart')->getQuote()->getAllItems(); $items = Mage::getSingleton('checkout/session')->getQuote()->getAllItems(); foreach($items as $item) { echo 'ID: '.$item->getProductId().'<br />'; echo 'Name: '.$item->getName().'<br />'; echo 'Sku: '.$item->getSku().'<br />'; echo 'Quantity: '.$item->getQty().'<br />'; echo 'Price: '.$item->getPrice().'<br />'; echo "<br />"; }
Get total items and total quantity in cart
$totalItems = Mage::getModel('checkout/cart')->getQuote()->getItemsCount(); $totalQuantity = Mage::getModel('checkout/cart')->getQuote()->getItemsQty();
Get subtotal and grand total price of cart
$subTotal = Mage::getModel('checkout/cart')->getQuote()->getSubtotal(); $grandTotal = Mage::getModel('checkout/cart')->getQuote()->getGrandTotal();
Hope this helps. Thanks.
转载地址:http://blog.chapagain.com.np/magento-get-all-shopping-cart-items-and-totals/
magento默认的购物车如下:
At line 34, 找到如下
<h2>
<?php if ($this->hasProductUrl()):?>
<a href=”<?php echo $this->getProductUrl() ?>”><?php echo $this->htmlEscape($this->getProductName()) ?></a>
<?php else: ?>
<?php echo $this->htmlEscape($this->getProductName()) ?>
<?php endif; ?>
</h2>
我们在下面加入如下代码:
<?php
$custom = Mage::getModel(‘catalog/product’)->load($_item->getProductId());
echo $custom->getShortDescription();
?>
将会出现下面的图片样子的short description:
当您有其他自己加入的属性也想让他显示出来,可以这样:如下!
<h2>
<?php if ($this->hasProductUrl()):?>
<a href=”<?php echo $this->getProductUrl() ?>”><?php echo $this->htmlEscape($this->getProductName()) ?></a>
<?php else: ?>
<?php echo $this->htmlEscape($this->getProductName()) ?>
<?php endif; ?>
</h2>
<?php
$custom = Mage::getModel(‘catalog/product’)->load($_item->getProductId());
echo $custom->getdimensions();
?>
<?php
$custom = Mage::getModel(‘catalog/product’)->load($_item->getProductId());
echo $custom->getShortDescription();
?>
在magento中发送消息,实例代码如下,含有失败和成功的方法,当做新的模块扩展的时候,在一些提交操作的成功和失败的判断的时候,可以使用下面代码进行判断是否成功和失败!
try {
$mail->send();
$message = $this->__('You have Register Successfully');
Mage::getSingleton('core/session')->addSuccess($message);
$this->_redirect('sendemail/index/wholesale');
}
catch(Exception $ex) {
// I assume you have your custom module.
// If not, you may keep 'customer' instead of 'yourmodule'.
Mage::getSingleton('core/session')
->addError(Mage::helper('yourmodule')
->__('Unable to send email.'));
$this->_redirect('sendemail/index/wholesale');
}
magento的邮件非常的领过,但是使用起来有点复杂,下面是实用的zend机制发送邮件的简单方法,如下:
public
function
sendEmail()
{
$fromName
=
"John Doe"
;
// sender name
$toName
=
"Mark Doe"
;
// recipient name
$body
=
"This is Test Email!"
;
// body text
$subject
=
"Test Subject"
;
// subject text
$mail
=
new
Zend_Mail();
$mail
->setBodyText(
$body
);
$mail
->setFrom(
$fromEmail
,
$fromName
);
$mail
->addTo(
$toEmail
,
$toName
);
$mail
->setSubject(
$subject
);
try
{
$mail
->send();
}
catch
(Exception
$ex
) {
// I assume you have your custom module.
// If not, you may keep 'customer' instead of 'yourmodule'.
Mage::getSingleton(
'core/session'
)
->addError(Mage::helper(
'yourmodule'
)
->__(
'Unable to send email.'
));
}
}
$mail
->setBodyHtml(
$body
);