Skip to content

Instantly share code, notes, and snippets.

View anunay's full-sized avatar
🏠
Working from home

Anunay Dahal anunay

🏠
Working from home
View GitHub Profile
@anunay
anunay / woocommerce_before_cart.php
Last active August 29, 2015 13:56
WooCommerce Before Cart
<?php
add_action( 'woocommerce_before_calculate_totals', 'add_custom_price' );
function add_custom_price( $cart_object ) {
$custom_price = 0; // This will be your custome price
//Your Custom Price Forumula goes here
$totalWeight = 50; // you can this variable value from post/get or cookie etc.
$unitWeight = 8; //8lbs default unit for basic unit price;
$unitPricePerWeight = (float) 0.44; //your unit price per 8lbs weight;
$noOfOrderDays = 10; // you can populate this varaible value from post/get/cookie or session.
@anunay
anunay / search_site.php
Created February 10, 2014 19:43
Search Site Model for FuelCMS
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Search_site extends MY_Model {
protected $_tables;
function __construct()
{
$CI =& get_instance();
@anunay
anunay / listfiles.php
Created February 11, 2014 06:42
List all files inside a directory
<?php
foreach (glob("*.txt") as $filename) {
echo "$filename size " . filesize($filename) . "\n";
}
?>
@anunay
anunay / listcode.php
Created February 13, 2014 14:34
listcode
<?php
fuel_set_var("page_title","Search");
$results = array();
$search = $this->load->model('search_model');
$current_page = $this->input->get("page");
$rowLimit = $this->input->get("limit");
$tabsource = $this->input->get("tab-source");
$tabcat = $this->input->get("tab-category");
$parameters["qs"] = $this->input->get("qs");
@anunay
anunay / magento-import-coupons-csv.php
Created February 13, 2014 21:57
Magento: Import Coupon Code with CSV
<?php
// Import coupon codes
// Thanks go out to Marius Strajeru
// Original URL: http://marius-strajeru.blogspot.nl/2010/04/create-bulk-discount-rules.html
require 'app/Mage.php';
Mage::app();
// Import CSV from ViArt format:
@anunay
anunay / temp.php
Created February 26, 2014 06:23
cpt slider
<?php
add_action('init', 'cptui_register_my_cpt_slider');
function cptui_register_my_cpt_slider() {
register_post_type('slider', array(
'label' => 'Slider',
'description' => 'Home Page Slider',
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
@anunay
anunay / integrate-dlg-with-aweber.html
Created April 21, 2014 19:19
Integrate DLG with Aweber
https://help.aweber.com/entries/21775378-how-do-i-integrate-dlguard-with-aweber
@anunay
anunay / p80.js
Created April 25, 2014 19:35
p80script
jQuery(function(){
/**
* Checking if cookie already exists, if so redirect to denied page.
*/
if($.cookie("pro80denied")=="true"){
location.href="denied/";
}
@anunay
anunay / magento-get-product-category-id.php
Last active August 29, 2015 14:01
Magento: Get category from product
<?php
// Magento: Getting categroy from product
$categoryIds = $_product->getCategoryIds();
if(count($categoryIds) ){
$firstCategoryId = $categoryIds[0];
$_category = Mage::getModel('catalog/category')->load($firstCategoryId);
echo $_category->getData('categorysecondimage');
}
@anunay
anunay / wp_admin_user_asso.php
Last active August 29, 2015 14:03
Wordpres: Admin user association
<?php
add_action( 'user_register', 'myplugin_registration_save', 10, 1 );
function myplugin_registration_save( $user_id ) {
$current_admin_user = wp_get_current_user();
if ( isset( $_POST['first_name'] ) ){
$user = new WP_User( $user_id );
$user_roles = $user->roles;
$user_role = array_shift($user_roles);
if($user_role!="administrator"){