Skip to content

Instantly share code, notes, and snippets.

View rintoug's full-sized avatar

Rinto George rintoug

View GitHub Profile
@rintoug
rintoug / validation.php
Created May 22, 2017 09:34
PHP User Registration Form
<?php
//Form validation
/* Form Required Field Validation */
foreach($_POST as $key=>$value) {
if(empty($_POST[$key])) {
$error[] = "All Fields are required";
break;
}
}
@rintoug
rintoug / form.php
Created May 22, 2017 09:32
PHP User Registration Form
<div class="container" style="width:500px;background:#E6EFCB;">
<?php if(!empty($error)):?>
<div class="alert alert-danger">
<?php foreach($error as $value):?>
<?php print $value?><br>
<?php endforeach;?>
</div>
<?php endif;?>
<?php if(isset($_GET['msg'])&& $_GET['msg']==1):?>
<div class="alert alert-success"> <strong>Success!</strong> Regsitered successfully. </div>
@rintoug
rintoug / attribute.php
Created May 21, 2017 07:26
How to get attribute option label/attribute text with option_id?
<?php
$product = Mage::getModel('catalog/product')-load(1000) //1000 is product id
$brandText = $product->getAttributeText('brand');
print $brandText
@rintoug
rintoug / broken-image.js
Created May 19, 2017 10:49
Broken Image Handling
// Replace source
$('img').error(function(){
$(this).attr('src', 'no-image.png');
});
// Or, hide them
$("img").error(function(){
$(this).hide();
});
@rintoug
rintoug / .htaccess
Created May 12, 2017 18:06
.htaccess “Down For Maintenance” Page Redirect
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} !^94\.12\.10\.148
RewriteCond %{REQUEST_URI} !^/maintenance\.html$
RewriteRule ^(.*)$ http://yourdomain.com/maintenance.html [R=307,L]
@rintoug
rintoug / .htaccess
Created May 12, 2017 18:05
.htaccess “Down For Maintenance” Page Redirect
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/maintenance\.html$
RewriteRule ^(.*)$ http://yourdomain.com/maintenance.html [R=307,L]
@rintoug
rintoug / redirect.phtml
Last active May 3, 2017 05:55
Create a Custom Payment Method Module in Magento - redirect.phtml
<?php
$order = new Mage_Sales_Model_Order();
$orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
$order->loadByIncrementId($orderId);
?>
<h2><?php echo $this->__('Tutsplanet Payment Gateway') ?></h2>
<p>It's a demo page acting as a payment gateway interface!</p>
<form name="custompaymentmethod" method="post" action="<?php echo Mage::helper('localpay')->getPaymentGatewayUrl(); ?>">
<input type="hidden" name="orderId" value="<?php echo $orderId; ?>">
<input type="submit" value="<?php echo $this->__('Make Payment') ?>"/>
@rintoug
rintoug / Tutsplanet_Localpay.xml
Last active May 3, 2017 06:25
Create a Custom Payment Method Module in Magento - system.xml
<?xml version="1.0"?>
<config>
<modules>
<Tutsplanet_Localpay>
<active>true</active>
<codePool>local</codePool>
<depends>
<Mage_Payment/>
</depends>
</Tutsplanet_Localpay>
@rintoug
rintoug / system.xml
Created May 3, 2017 05:53
Create a Custom Payment Method Module in Magento - system.xml
<?xml version="1.0"?>
<config>
<sections>
<payment>
<groups>
<localpay translate="label" module="localpay">
<label>Localpay</label>
<sort_order>1000</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
@rintoug
rintoug / PaymentController.php
Created May 3, 2017 05:52
Create a Custom Payment Method Module in Magento - PaymentController.php
<?php
// app/code/local/Tutsplanet/Localpay/controllers/PaymentController.php
class Tutsplanet_Localpay_PaymentController extends Mage_Core_Controller_Front_Action
{
/**
* Rendering the layout
*/
public function redirectAction()