Skip to content

Instantly share code, notes, and snippets.

View zarankumar's full-sized avatar

sarankumar zarankumar

View GitHub Profile
/** Custom Tabs for Opening Hours. **/
function opening_hours_options_tab() {
?>
<li class="opening_hours"><a href="#opening_hours_data"><?php _e('Cab Price Settings', 'yatramantra'); ?></a></li>
<li class="opening_hours"><a href="#opening_hours_data"><?php _e('Hotel Price Settings', 'yatramantra'); ?></a></li>
<?php
}
add_action('woocommerce_product_write_panel_tabs', 'opening_hours_options_tab');
/**
@zarankumar
zarankumar / woo sale price
Created October 3, 2015 18:12
Woocommerce set sale price to regular price - 15% discount
function so_31493236_sale_price( $sale_price, $product ) {
$sale_price = $product->get_regular_price() * 0.15;
return $sale_price;
}
add_filter( 'woocommerce_get_sale_price', 'so_31493236_sale_price', 10, 2 );
// First Register the Tab by hooking into the 'woocommerce_product_data_tabs' filter
add_filter( 'woocommerce_product_data_tabs', 'add_my_custom_product_data_tab' );
function add_my_custom_product_data_tab( $product_data_tabs ) {
$product_data_tabs['my-custom-tab'] = array(
'label' => __( 'My Custom Tab', 'my_text_domain' ),
'target' => 'my_custom_product_data',
);
return $product_data_tabs;
}
<?php
add_filter( 'woocommerce_email_attachments', 'attach_terms_conditions_pdf_to_email', 10, 3);
function attach_terms_conditions_pdf_to_email ( $attachments , $id, $object ) {
$your_pdf_path = get_template_directory() . '/terms.pdf';
$attachments[] = $your_pdf_path;
return $attachments;
}
@zarankumar
zarankumar / gist:063eca3292f0f764d039
Last active August 29, 2015 14:25
Simple send an email via Mandrill API. I could not find this anywhere else so hopefully it is helpful to somebody else. At this point you should be able to look at the api docs and figure out the different options.
// Send Email
require_once 'Mandrill.php';
$mandrill = new Mandrill($apikey);
$message = new stdClass();
$message->html = "html message";
$message->text = "text body";
$message->subject = "email subject";
$message->from_email = "address@test.com";
@zarankumar
zarankumar / mint-login.txt
Last active August 29, 2015 14:25
Desable Automatic Guest login in Mint 17 or Remove automatic login
Login to super user
su <password>
sudo gksudo mdmsetup
@zarankumar
zarankumar / db-plugin
Last active August 29, 2015 14:24 — forked from ahmad24/db-plugin
<?php
/*
Plugin Name: Dashboard Widget Example Plugin
Plugin URI: http://example.com/wordpress-plugins/my-plugin
Description: A plugin to create dashboard widgets in WordPress
Version: 1.0
Author: Brad Williams
Author URI: http://wrox.com
License: GPLv2
*/
<?php
/*
Plugin Name: Widget Example Plugin
Plugin URI: http://example.com/wordpress-plugins/my-plugin
Description: A plugin to create widgets in WordPress
Version: 1.0
Author: Brad Williams
Author URI: http://wrox.com
License: GPLv2
*/
@zarankumar
zarankumar / Readme.md
Last active August 29, 2015 14:24 — forked from mrgcohen/Readme.md

Requirements

  • bootstrap with typeahead
  • jquery

Explanation

This will use bootstrap with typeahead to create an autocomplete search.

/**
* This function allows you to retrieve the wp_get_attachment_image_src()
* data for any post's featured image on your network. If you are running
* a multisite network, you can supply another blog's ID to retrieve a post's
* featured image data from another site on your WordPress multisite network.
*
* Does not take care of icon business (at this time).
*
* If successful, this function returns an array of the following:
* [0] => url