$value = 100.25;
echo number_format($value, 2);
Shopify, Shopify Apps, Magento, WordPress, Codeigniter, Joomla, Big Commerce | PHP
Monday, 4 April 2016
How to add 00 after a number in php
Curl automatically display the result? / Without print, response is displayed me in CURL php
By default, the curl extension prints out the result.
You need to enable the CURLOPT_RETURNTRANSFER option, like so:
After that option is enabled, curl_exec will return the result, instead.
You need to enable the CURLOPT_RETURNTRANSFER option, like so:
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
After that option is enabled, curl_exec will return the result, instead.
Thursday, 31 March 2016
How to create import functionality on grid page in magneto
Open Grid.php
protected function _prepareMassaction()
{
..................
..................
//Upload your csv file into var/import directory
$dir = new DirectoryIterator(Mage::getBaseDir() . DS . 'var' . DS . 'import' . DS);
$extensions = "csv";
$csv = array();
foreach ($dir as $fileinfo) {
if ($fileinfo->isFile() && stristr($extensions, $fileinfo->getExtension())) {
$csv[$fileinfo->getFilename()] = $fileinfo->getFilename();
}
}
$csv = array_merge(array(''=>'Please select'),$csv);
$this->getMassactionBlock()->addItem('import', array(
'label' => Mage::helper('metizsoft_taxgenerate')->__('Import'),
'url' => $this->getUrl('*/*/massCsv', array('_current'=>true)),
'confirm' => Mage::helper('metizsoft_taxgenerate')->__('Are you sure?'),
'additional' => array(
'subgroup' => array(
'name' => 'csv',
'type' => 'select',
'class' => 'required-entry',
'label' => Mage::helper('customer')->__('Select Csv'),
'values' => $csv
)
)
));
return $this;
}
Open your controller file. and put this code.public function massCsvAction()
{
$csvfile = $this->getRequest()->getParam('csv');
if (!$csvfile) {
Mage::getSingleton('adminhtml/session')->addError(
Mage::helper('metizsoft_taxgenerate')->__('Please select statetaxs.')
);
} else {
try {
$csv = new Varien_File_Csv;
$csvpath = Mage::getBaseDir() . DS . 'var' . DS . 'import' . DS . $csvfile;
$datas = $csv->getData($csvpath);
print_r($datas);
} catch (Mage_Core_Exception $e) {
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError(
Mage::helper('metizsoft_taxgenerate')->__('There was an error updating statetaxs.')
);
Mage::logException($e);
}
}
$this->_redirect('*/*/index');
}
Monday, 28 March 2016
How to get Controller, Action/Function/Method, URL informations in CodeIgniter PHP
You could use the URI Class:
$this->uri->segment(n); // n=1 for controller, n=2 for method, etcYou can also use this in-built functions of codeigniter.
$this->router->fetch_class();
$this->router->fetch_method();
Saturday, 26 March 2016
Remove specific color/white/Black from any type of image
//header('Content-type: image/png');
$strInputFile = '20160312105210_girls.jpg';
$target = 'car_transparent.png';
$im = new Imagick($strInputFile);
//$im->paintTransparentImage($im->getImageBackgroundColor(), 0, 10000);
$im->paintTransparentImage('#000', 0, 10000); //Which color you need to remove #000
$im->setImageFormat('png');
//$im->writeImage($target);
$im->destroy();
//echo $im;
Saturday, 13 February 2016
Get customer addresses with admin formated
$order = $this->getOrder();
$address = $order->getShippingAddress()->getFormated(true);
echo $address;
Thursday, 11 February 2016
How to display product option/variant in category page in woocommerce wordpress
<?php
/**
* woocommerce_after_shop_loop_item_title hook
*
* @hooked woocommerce_template_loop_rating - 5
* @hooked woocommerce_template_loop_price - 10
*/
do_action( 'woocommerce_after_shop_loop_item_title' );
?>
</a>
<?php do_action( 'woocommerce_after_shop_loop_item' ); ?>
with this:
<?php
/**
* ADD PRODUCT VARIABLE WITH ADD TO CART ON CATALOG PAGE
ADDED BY GW
**/
?>
<div class="catbox">
<?php
//ADD SHORT DESCRIPTION TO PRODUCT
add_action('woocommerce_after_shop_loop_item_title','woocommerce_template_single_excerpt', 5); ?>
<?php
/**
* woocommerce_after_shop_loop_item_title hook
*
* @hooked woocommerce_template_loop_rating - 5
* @hooked woocommerce_template_loop_price - 10
*/
do_action( 'woocommerce_after_shop_loop_item_title' );
?>
<?php do_action( 'woocommerce_after_shop_loop_item' ); ?>
<?php
//ADD VARIATIONS BEFORE ADD TO CART
if($product->product_type == "variable"){
woocommerce_variable_add_to_cart();
} else {
woocommerce_template_loop_add_to_cart();
}
?>
</div>
Subscribe to:
Posts (Atom)