shatner_label = get_option('shatner_label', "Name your own price"); wp_enqueue_script('shatner', plugins_url('/shatner.js',__FILE__), array('jquery') ); if ( is_admin() ){ // admin actions $this->init_form_fields(); add_action( 'admin_menu', array($this, 'add_shatner_menu' )); add_action( 'admin_init', array($this, 'admin_init' )); add_action('woocommerce_before_calculate_totals', array($this, 'add_custom_price' )); add_action('woocommerce_product_options_pricing', array($this, 'add_donation_radio')); add_action('save_post', array($this, 'set_named_price')); } else { if(get_option('use_shatner_templates', 1 ) == 1) { add_filter('woocommerce_locate_template', array($this, 'template_override'),10,3); add_filter('woocommerce_loop_add_to_cart_link', array($this, 'remove_link'),10); } add_action('woocommerce_product_options_pricing', array($this, 'add_donation_radio')); add_action('save_post', array($this, 'set_named_price')); add_action('woocommerce_add_to_cart', array($this, 'add_to_cart_hook')); add_action('woocommerce_before_calculate_totals', array($this, 'add_custom_price' )); add_action('init', array($this, 'init_css')); } } public function remove_link($link) { global $post; $post = get_post_meta($post->ID, '_own_price', true); if ($post === 'yes') return ''; return $link; } public function add_shatner_menu() { add_options_page( 'Shatner Plugin Settings', 'Shatner Settings', 'manage_options', 'shatner_plugin', array($this, 'shatner_plugin_settings_page') ); } public function shatner_plugin_settings_page() { include(sprintf("%s/templates/settings.php", dirname(__FILE__))); } /** * hook into WP's admin_init action hook */ public function admin_init() { // add your settings section add_settings_section( 'wp_plugin_template-section_shatner', 'Shatner Plugin Template Settings', array($this, 'settings_section_shatner_plugin_template'), 'wp_plugin_template_shatner' ); foreach($this->form_fields as $setting) { // register your plugin's settings register_setting('wp_plugin_template-group-shatner', $setting['title']); // add your setting's fields add_settings_field( $setting['title'], $setting['description'], array(&$this, 'settings_field_input_'. $setting['type']), 'wp_plugin_template_shatner', 'wp_plugin_template-section_shatner', array( 'field' => $setting['title'] ) ); } } // END public static function activate public function init_form_fields() { $this->form_fields = array( array( 'type' => 'text', 'title' => __('shatner_label', 'woothemes'), 'description' => __('Shatner Label', 'woothemes'), 'default' => __('Name your own price', 'woothemes') ), array( 'type' => 'radio_button', 'title' => __('use_shatner_templates', 'woothemes'), 'description' => __('Shatner Templates override pricing, disable if you want to customize using your theme', 'woothemes'), 'default' => __('1', 'woothemes') ) ); } public function settings_section_shatner_plugin_template() { // Think of this as help text for the section. echo 'These settings set values for Shatner'; } /** * This function provides text inputs for settings fields */ public function settings_field_input_text($args) { // Get the field name from the $args array $field = $args['field']; // Get the value of this setting $value = get_option($field); // echo a proper input type="text" echo sprintf('', $field, $field, $value); } // END public function settings_field_input_text($args) /** * This function provides text inputs for settings fields */ public function settings_field_input_radio_button($args) { // Get the field name from the $args array $field = $args['field']; // Get the value of this setting $value = get_option($field); $html = ' '; $html .= '
'; $html .= ' '; $html .= ' '; echo $html; } // END public function settings_field_input_radio($args) public function template_override($template, $template_name, $template_path ) { // Modification: Get the template from this plugin, if it exists $plugin_path = untrailingslashit( plugin_dir_path( __FILE__ ) ). '/templates/'; if ( file_exists( $plugin_path . $template_name ) ) { $template = $plugin_path . $template_name; return $template; } return $template; } public function init_css() { wp_register_style('donation_css', plugins_url('custom_styles.css',__FILE__ ), false, '1.0.1', 'all'); wp_enqueue_style( 'donation_css' ); } public function add_to_cart_hook($key) { global $woocommerce; foreach ($woocommerce->cart->get_cart() as $cart_item_key => $values) { if(!get_post_meta($values['product_id'], '_own_price', true ) || get_post_meta($values['product_id'], '_own_price', true ) === 'no') { $values['data']->set_price($_POST['price']); continue; } $thousands_sep = wp_specialchars_decode( stripslashes( get_option( 'woocommerce_price_thousand_sep' ) ), ENT_QUOTES ); $decimal_sep = stripslashes( get_option( 'woocommerce_price_decimal_sep' ) ); $_POST['price'] = str_replace($thousands_sep, '', $_POST['price']); $_POST['price'] = str_replace($decimal_sep, '.', $_POST['price']); $_POST['price'] = woocommerce_format_total($_POST['price']); error_log(var_export($_POST,1)); if($cart_item_key == $key) { $values['data']->set_price($_POST['price']); $woocommerce->session->__set($key .'_named_price', $_POST['price']); } } return $key; } public function set_named_price($post) { if($_POST['_own_price']){ if(!get_post_meta($_POST['post_ID'], '_own_price', true )){ add_post_meta($_POST['post_ID'], '_own_price', $_POST['_own_price']); } else { update_post_meta($_POST['post_ID'], '_own_price', $_POST['_own_price']); } } if($_POST['_own_price_enforce_minimum']){ if(!get_post_meta($_POST['post_ID'], '_own_price_enforce_minimum', true )){ add_post_meta($_POST['post_ID'], '_own_price_enforce_minimum', $_POST['_own_price_enforce_minimum']); } else { update_post_meta($_POST['post_ID'], '_own_price_enforce_minimum', $_POST['_own_price_enforce_minimum']); } } } public function add_donation_radio($content) { global $post; woocommerce_wp_radio(array( 'id' => '_own_price', 'class' => 'wc_own_price short', 'label' => __( 'Name your own price', 'woocommerce' ), 'options' => array( 'yes' => 'yes', 'no' => 'no', ) ) ); woocommerce_wp_radio(array( 'id' => '_own_price_enforce_minimum', 'class' => 'wc_own_price_e short', 'label' => __( 'Enforce minimum price (Regular Price)', 'woocommerce' ), 'options' => array( 'yes' => 'yes', 'no' => 'no', ) ) ); } public function add_custom_price( $cart_object ) { global $woocommerce; foreach ( $cart_object->cart_contents as $key => $value ) { if(!get_post_meta($value['product_id'], '_own_price', true ) || get_post_meta($value['product_id'], '_own_price', true ) === 'no') { continue; } $named_price = $woocommerce->session->__get($key .'_named_price'); if($named_price) { $value['data']->price = $named_price; } } } } new SV_WC_Donation(); India | The Holiday Company

Hyderabad – a city filled with food, culture and history

With almost no thought but to catch up with some friends and spend an expiring travel voucher, I booked my tickets to Hyderabad for a 3 day solo trip. Closer to the dates, my research started on what to eat and where to go. I had a lot of help via The Travelling People group on Facebook – especially, on things to eat and I noted them all down, already dreamy about delicacies I’d get to try. My 3 day weekend turned out exactly how I had envisioned it – lots of food, culture and history. In all, I think 3 days is exactly what I required to explore the city.

Here is where all I went including some funny things I got to know about Hyderabadi’s as quoted by Hyderabad locals.

Read More


A weekend in Rishikesh, beyond river rafting

I have visited Rishikesh about three to four times over the last few years as a weekend destination from New Delhi. Always, the agenda has been quite simple. Check-in to a camp site, head out for a thrilling rafting expedition and  after an exhilarating few hours in the  river head back to the camp site. Ending the day with a usually quite and relaxed evening on the banks of the Ganges.

The plan does vary person to person, group to group, but if I may allow myself to generalise a little, the itinerary pretty much remains the same for people looking for a weekend getaway in Rishikesh.  Of course let’s not forget that Rishikesh is also famously known for it being a Yoga and mediation destination. Ashrams  can be seen at every corner but then a trip like this would require much more time than a just weekend.

Read More


Hotel Review: Courtyard House, Kanha National Park

Kanha National Park is known for its Tiger spotting; hundreds of people flock to this park every year from across India and overseas in the hope to see a Tiger. My suggestion, visit this park for reasons beyond the king of the jungle. This jungle can also make for a memorable holiday if you are looking for some peace and quality time with family and friends.

While planning our accommodation in Kanha, we decided to stay away from the popular hotels mentioned online and chose to stay at a boutique hotel called Courtyard House. A quaint house with its exterior walls painted a warm yellow,  it is perched on a slight height and can be spotted from a mile away. Literally, off the beaten track the house is situated in the buffer zone of the Kanha Tiger Reserve and the view of the jungle from the house extends as far as the eyes can see.

Read More


Hotel Review: Forsyth Lodge, Satpura National Park

A last minute booking, we arrived at Forsyth Lodge for a night but ended up extending  our stay by another. As one enters the premise, it is clear that the lodge is built and put together by a team of people who are passionate about the wilderness and the environment. An eco-friendly lodge, Forsyth is set within 44 acres of rehabilitated jungle on the edge of Satpura National Park; this was the first property to also be constructed near the park.

Read More


Bhopal, an interesting weekend destination

In an attempt to hunt down a new weekend destination near the Capital,  Bhopal came up as an interesting option if looking for a mix of history, heritage, wildlife, and of course some luxury. This city has the ability to thrill and pamper.

I had no expectations from Bhopal when we visited, it was meant to be a one night stop during our 2 weeks Madhya Pradesh road trip. However, once I spent some time here, I realised that this city has much more to offer then then just being the political hub of Madhya Pradesh.

While we could not stay longer than a night, I promised myself I would return soon to enjoy a little more of everything.

Read More


Hotel review: Deo Bagh Neemrana, Gwalior

A seven hour drive from New Delhi (via the Yamuna Expressway), Gwalior city is typically not known a holiday destination, unless of course you are travelling to Orchaa, Khajuraho, Shivpuri or even Bhandhavgarh Tiger Reserve.

Since we were on a two week road trip through Madhya Pradesh, Gwalior was a good option for us to take our first overnight stop between Delhi and Orchaa.  We had pre-booked a room in Deo Bagh Neemrana,  a heritage property located amidst two 17th and 18th century Maratha temples a hathi khana for elephants, stables and two cenotaphs.

Read More


Time to get back on the road

Road trips are one way of holidaying I thoroughly enjoy and I have been quite regular with short trips in and around North India for many years now. But it’s been over 10 years since I did my last long distance trip. It was from Delhi to Goa spanning over a month covering 7 states and 22 cities.

I am heading to Madhya Pradesh for two weeks. Unlike the Delhi-Goa trip where I travelled with my buddies, this time, my wife is my companion along with her trusted Ford Figo.

Read More


Goa, the eclectic zone

I wrote this back in 2004 after a month long road trip from Delhi to Goa.

Goa…the destination that speaks of holidays…of relaxation and of letting down your hair. The golden beaches of north Goa, the white sands of South Goa…the shacks and sun beds that dot the beaches, the colourful sun umbrellas…the white bodies that lie here desperately trying to tan themselves under the soothing Goa sun, the gallons of beer that are consumed daily here.

This was not my first trip to Goa. I had been to Goa quite often before, but all the previous trips had been on business.

Read More