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
// Add Downloadable Products to Woocommerce Completed Order & Invoice Emails as Attachments
add_filter( 'woocommerce_email_attachments', 'woocommerce_emails_attach_downloadables', 10, 3);
function woocommerce_emails_attach_downloadables($attachments, $status, $order) {
if ( ! is_object( $order ) || ! isset( $status ) ) {
return $attachments;
}
if ( empty( $order ) ) {
1. Change post title in post list column
add_action(
'admin_head-edit.php',
'wpse152971_edit_post_change_title_in_list'
);
function wpse152971_edit_post_change_title_in_list() {
add_filter(
'the_title',
'wpse152971_construct_new_title',
100,
<nav class="top-bar foundation-bar" data-topbar>
<ul class="title-area">
<li class="name">
<span data-tooltip class="has-tip" title="Try resizing your browser to see how the grid stacks"><h1 class="show-for-small-only"><a href="#">Small screen</a></h1></span>
<span data-tooltip class="has-tip" title="Try resizing your browser to see how the grid stacks"><h1 class="show-for-medium-only"><a href="#">Medium Screen</a></h1></span>
<span data-tooltip class="has-tip" title="Try resizing your browser to see how the grid stacks"><h1 class="show-for-large-only"><a href="#">Large screen</a></h1></span>
</li>
</ul>
<section class="top-bar-section">
<!-- Right Nav Section -->
@zarankumar
zarankumar / Foundation 5 Tabs to Accordion
Created October 14, 2015 13:43
Foundation 5 Tabs to Accordion
<div class="row">
<div class="small-12 columns">
<ul class="tabs show-for-medium-up" data-tab>
<li class="tab-title active"><a href="#panel1">Tab / Accordion 1</a></li>
<li class="tab-title"><a href="#panel2">Tab / Accordion 2</a></li>
<li class="tab-title"><a href="#panel3">Tab / Accordion 3</a></li>
<li class="tab-title"><a href="#panel4">Tab / Accordion 4</a></li>
<li class="tab-title"><a href="#panel5">Tab / Accordion 5</a></li>
</ul>
add_action( 'woocommerce_product_write_panel_tabs', 'woo_add_custom_admin_product_tab' );
function woo_add_custom_admin_product_tab() {
?>
<li class="custom_tab"><a href="#custom_tab_data"><?php _e('Price Settings', 'woocommerce'); ?></a></li>
<?php
}
add_action( 'woocommerce_product_options_general_product_data', 'wdm_add_custom_settings' );
// add a product type
add_filter( 'product_type_selector', 'wdm_add_custom_product_type' );
function wdm_add_custom_product_type( $types ){
$types[ 'wdm_custom_product' ] = __( 'Tour package' );
return $types;
}
add_action( 'plugins_loaded', 'wdm_create_custom_product_type' );
function wdm_create_custom_product_type(){
// declare the product class
class WC_Product_Wdm extends WC_Product{
add_filter('woocommerce_cart_item_name','ym_package_name');
function ym_package_name()
{
$wp_session = WP_Session::get_instance();
return "Customized Kerala Tour Package";
}