Skip to content

Instantly share code, notes, and snippets.

View zarankumar's full-sized avatar

sarankumar zarankumar

View GitHub Profile
@zarankumar
zarankumar / woocommerce-custom-cart-item-data.php
Created April 8, 2017 14:25 — forked from RadGH/woocommerce-custom-cart-item-data.php
Get and set custom cart item/product information prior to WooCommerce checkout, and carry those valus over to Order Item Metadata.
<?php
// UPDATE: Stefan from Stack Overflow has explained a better way to handle cart item data.
// See http://stackoverflow.com/a/32327810/470480
// ----------------------
/*
Instructions:
@zarankumar
zarankumar / edit-woocommerce-checkout-template.php
Created December 29, 2016 05:33 — forked from bekarice/edit-woocommerce-checkout-template.php
Add content and notices to the WooCommerce checkout - sample code
/**
* Each of these samples can be used - note that you should pick one rather than add them all.
*
* How to use WC notices: https://github.com/woothemes/woocommerce/blob/master/includes/wc-notice-functions.php#L96
* Tutorial: http://www.skyverge.com/blog/edit-woocommerce-templates/
**/
/**
* Add a content block after all notices, such as the login and coupon notices.
*
@zarankumar
zarankumar / add-wordpress-settings-page.php
Created June 4, 2016 13:04 — forked from DavidWells/add-wordpress-settings-page.php
WordPress :: Add Settings Page with All Fields
<?php
/*
Plugin Name: Homepage Settings for BigBang
Plugin URI: http://www.inboundnow.com/
Description: Adds additional functionality to the big bang theme.
Author: David Wells
Author URI: http://www.inboundnow.com
*/
// Specify Hooks/Filters
// 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 = "[email protected]";
@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