Hey I was wondering about magento Retail/Wholesale capabilities.
The main store will be for normal customers (retail) and they see normal prices but for wholesalers they need to login and see wholesale prices?
I don't want normal visitors to see wholesale prices.
Is that possible?
Assign product price as customer groups after that use this code on list or view page, you will see product different price on both side same and equal to admin price.
<?php $groupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
if($groupId ==1 || $groupId ==""){?>
<?php if($product->getSpecialPrice()){?>
<?php echo "$".$rprice = number_format($product->getPrice(),2); ?> </div>
<?php }else{?>
<?php $product->setCustomerGroupId($groupId);
echo "$".$price = number_format($product->getPriceModel()->getFinalPrice(1, $product),2); ?>
<?php } ?>
</div>
<?php if($product->getSpecialPrice()){ echo "Special Price $".number_format($product->getSpecialPrice(),2);?>
<?php } ?>
<?php }else{echo "$".$price = number_format($product->getPriceModel()->getFinalPrice(1, $product),2); }
?>
for create customer group check this link:
http://www.magentocommerce.com/knowledge-base/entry/customer-groups
Related
I'm trying to to switch the price for a 'Sold' label on the product page of products that are out of stock.
If a product is sold out, the price should be hidden and in its stead should be a 'Sold' label.
I figured out that the price is placed in catalog_product_view.xml and it calls upon the vendor/magento/module-catalog/view/base/templates/product/price/final_price.phtml file, but I could not figure out where and how to bring in a condition to check whether product is sold out or not.
Can someone help here?
Thanks in advance.
Yuan
As I understand you have two parts to this issue
1) Hide price on Product-detail page if product is Out-of-stock
Prices are defined in vendor/magento/module-catalog/view/frontend/layout/catalog_product_view.xml
called at class: Magento\Catalog\Pricing\Render and method: _toHtml()
You can override the method using DI to below
protected function _toHtml()
{
/** #var PricingRender $priceRender */
$priceRender = $this->getLayout()->getBlock($this->getPriceRender());
if ($priceRender instanceof PricingRender) {
$product = $this->getProduct();
if ($product instanceof SaleableInterface && $product->isAvailable()) {
$arguments = $this->getData();
$arguments['render_block'] = $this;
return $priceRender->render($this->getPriceTypeCode(), $product, $arguments);
}
}
return parent::_toHtml();
}
$product->isAvailable() is the new condition that we have added
2) Show Sold label
outofstock label is shown by default, but if you still want to show create your block & template in vendor/magento/modul-catalog/view/frontend/layout/catalog_product_view.xml
and $product->isAvailable() function to check product's availability
Hope this helps
Hiding price for out of stock products in Magento 1.
RWD Theme
app/design/frontend/rwd/template/catalog/product/view.phtml
Change
<div class="price-info">
<?php echo $this->getPriceHtml($_product); ?>
<?php echo $this->getChildHtml('bundle_prices') ?>
<?php echo $this->getTierPriceHtml() ?>
</div>
To:
<?php if($_product->isSaleable()): ?>
<div class="price-info">
<?php echo $this->getPriceHtml($_product); ?>
<?php echo $this->getChildHtml('bundle_prices') ?>
<?php echo $this->getTierPriceHtml() ?>
</div>
<?php endif; ?>
Default Theme:
\app\design\frontend\base\default\template\catalog\product\view\type\default.phtml
Change
<?php echo $this->getPriceHtml($_product) ?>
To:
<?php if($_product->isSaleable()): ?>
<?php echo $this->getPriceHtml($_product) ?>
<?php endif; ?>
OR
Hiding price for out of stock products in Magento 2.
On admin page, Click on Stores, then under the Setting section, choose Configuration.
In this page, you find the Inventory section under Catalog. Expand the Stock Options section and you can start to set the custom status of the product.
Before coming to the Out of stock product section, you need to enter this field.
Set Items’ Status to be in Stock When Order in Canceled: You choose YES when you want to return items to your stock if an order is canceled.
Decrease Stock When Order is Placed: if you want to adjust the quantity on hand when the order is placed, you choose Yes
Then we can come to the part that allows you to display or disable the product out of stock in Magento 2.
You want to display the product out of stock, you set the Display Out of Stock Products section is Yes. In contrast, set No if you want to disable it.
I am trying to display category name in product detail page. For that I am using
$cat_name=Mage::registry('current_category')->getName();
It shows category name.
But when I went to wishlist page & click to product image then it give error:-
Fatal error: Call to a member function getName() on a non-object in /opt/lampp/htdocs/dominie/app/design/frontend/default/dominie/template/catalog/product/view.phtml.
Please help me how can I solve this issue.
Just tested the code below and it work in v1.7 when added to template/catalog/product/view.phtml.
However Mage::registry('current_category'); is only available if when coming to a product page from a category page (not tested, but may also dependent on if you have seo url that contain the category names within the url)
<?php
$_helper = $this->helper('catalog/output');
$_category_detail=Mage::registry('current_category');
echo $_category_detail->getName(); //gives current category name
echo $_category_detail->getId(); //gives current category id
?>
See http://vinayp.com.np/how-to-get-category-name-and-id-on-product-page-on-magento/
To display all the categories that a product belong to do
<?php $categories = $_product->getCategoryIds(); ?>
<?php foreach($categories as $k => $_category_id): ?>
<?php $_category = Mage::getModel('catalog/category')->load($_category_id) ?>
<?php echo $_category->getName() ?>
<?php endforeach; ?>
See http://www.magentocommerce.com/boards/viewthread/27720/
Try to define $cat_name in your wishlist module so that collection from wishlist module will also contain category name from which it was added to wishlist. This will surely reduce your overhead.
I want to display the product options value in a Magento Product Page. I tried this code:
<?php echo $_product->getAttributeText('color'); ?>
but the options are not showing up.
If you are on the actual product view paghe you can use a helper to get what you want:
echo $_helper->productAttribute($_product, $_product->getColor(), 'color');
or
echo $_helper->productAttribute($_product, $_product->getData('attribute_code'), 'attribute_code');
Alternatively you can try this:
$_product->getResource()->getAttribute('color')->getFrontend()->getValue($_product);
you can this one,
<?php $attributeValue = Mage::getModel('catalog/product')->load($_product->getId())->getColor();?>
I'm having problems trying to show the original unit price in the shopping cart in Magento. By default Magento only shows the special price but I would like to also show the original price to highlight the savings.
I know which template needs changing which is /template/checkout/cart/item/default.phtml.
On line 145 it shows
<?php
echo $this->helper('checkout')->
formatPrice($_incl-$_item->getWeeeTaxDisposition())
?>
which displays the special price. I just don't know the syntax to display the original price.
see below for an alternative method,
i'm not sure if $_item->getPrice has access to the non special price, so jumped it over to product
<?php echo $_item->getProduct()->getPrice(); ?>
within
<?php foreach($this->getItems() as $_item): ?>
<?php echo $this->getItemHtml($_item) ?>
// insert it here
<?php endforeach ?>
I want to setup the category catalog pages in Magento such that the first page contains the category image and the first three products in that category. Then the following pages contain six products per page without the category image.
I can't figure out how this can be done.
Unfortunately I don't think you can do this without a lot of work. You'll need to rewrite the logic of the pagination, change the page size depending on which page it is, & offset the returned collection.
However you can easily only have the category image displayed on the first page.
This line returns the current page number:
Mage::getBlockSingleton('page/html_pager')->getCurrentPage();
So in template/catalog/category/view.phtml you can just do a conditional around the category image display, find the section:
<?php if($_imgUrl): ?>
<?php echo $_imgHtml ?>
<?php endif; ?>
and replace it with:
<?php if($_imgUrl): ?>
<?php if(Mage::getBlockSingleton('page/html_pager')->getCurrentPage()==1):?>
<?php echo $_imgHtml ?>
<?php endif; ?>
<?php endif; ?>