Add Custom Price in your woocommerce cart before calculate

Fixed Custom Value you want to add in All product


add_action( 'woocommerce_before_calculate_totals', 'add_custom_price' );
function add_custom_price( $cart_object ) {
   $custom_price = 100; //Custom price you want to add
   $value['data']->price = $value['data']->price + $custom_price;
}

Add an Extra Cost ( 10% of Actual Price ) based on SIZE Attribute


add_action( 'woocommerce_before_calculate_totals', 'add_custom_price' );

function add_custom_price( $cart_object ) {

    foreach ( $cart_object->cart_contents as $key => $value ) {

        $p_size = $value['variation'][attribute_pa_size];//Get Attribute size

	if($p_size >= 44)
	{
		$c_price = $value['data']->price;
		$cp_10 = $c_price * 10/100; 
		$value['data']->price = $value['data']->price + $cp_10;
	}

    }
}

It just an example you can use any attribute or any condition

How to Create and Use Custom post Type in WordPress

Copy This Code and Paste in Your themes function.php


add_action('init', 'register_mypost_type');
function register_mypost_type() {
register_post_type('people',
		array(	'label' => 'People',
		'public' => true,'show_ui' => true,
		'show_in_menu' => true,
		'capability_type' => 'post',
		'hierarchical' => false,
		'rewrite' => array('slug' => ''),
		'query_var' => true,
		'has_archive' => true,
		'supports' => array('title','editor','thumbnail',),
		'taxonomies' => array('category',),
		'menu_position' => 5,
				) );
}

Copy This Code and Paste in Your template page where you want to use this Custom post


$args = array( 'post_type' => 'people', 'posts_per_page' => 10 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
	the_title();
	echo '<div>';
	the_content();
	echo '</div>';
endwhile;

woocommerce-travelify

Show Product Category Image on Product Page in Woo Commerce

1. Go to the:-  /wp-content/plugins/woocommerce/templates/single-product

2. Find and Edit meta.php

3. Find this Code:-

<?php
$size = sizeof( get_the_terms( $post->ID, ‘product_cat’ ) );
echo $product->get_categories( ‘, ‘, ‘<span class=”posted_in”>’ . _n( ‘Artist:’, ‘Artist:’, $size, ‘woocommerce’ ) . ‘ ‘, ‘.</span>’ );
?>

4. Replace With :-

<span class=”posted_in”>
<?php
$prod_categories = get_the_terms($post->ID, ‘product_cat’ );
foreach( $prod_categories as $prod_cat ) :
$cat_thumb_id = get_woocommerce_term_meta( $prod_cat->term_id, ‘thumbnail_id’, true );
$cat_thumb_url = wp_get_attachment_thumb_url( $cat_thumb_id );
$term_link = get_term_link( $prod_cat, ‘product_cat’ );
?>

<a href=”<?php echo $term_link; ?>”>
<?php if($cat_thumb_url){ ?>
<span class=”artist-name”><img src=”<?php echo $cat_thumb_url; ?>” alt=”<?php echo $prod_cat->name; ?>” /></span>
<?php } ?>
<span class=”artist-image”><?php echo $prod_cat->name; ?></span>
</a>

<?php endforeach; wp_reset_query(); ?>
</span>

Add Extra Field in WordPress Comments Form

Add Custom Field

function add_comment_fields($fields) {$fields['country'] = ‘<p class=”comment-form-country”><label for=”country”>’ . __( ‘Country’ ) . ‘</label>’ .
‘<input id=”country” name=”country” type=”text” size=”30″ /></p>';
$fields['oldpro'] = ‘<p class=”comment-form-oldpro”><label for=”oldpro”>’ . __( ‘Old Profession’ ) . ‘</label>’ .
‘<input id=”oldpro” name=”oldpro” type=”text” size=”30″ /></p>';
$fields['ref'] = ‘<p class=”comment-form-ref”><label for=”ref”>’ . __( ‘Reference’ ) . ‘</label>’ .
‘<input id=”ref” name=”ref” type=”text” size=”30″ /></p>';
return $fields;}
add_filter(‘comment_form_default_fields’,’add_comment_fields’);

Add Value

function add_comment_meta_values($comment_id) {if(isset($_POST['country'])) {
$country = wp_filter_nohtml_kses($_POST['country']);
add_comment_meta($comment_id, ‘country’, $country, false);
}
if(isset($_POST['oldpro'])) {
$oldpro = wp_filter_nohtml_kses($_POST['oldpro']);
add_comment_meta($comment_id, ‘oldpro’, $oldpro, false);
}
if(isset($_POST['ref'])) {
$ref = wp_filter_nohtml_kses($_POST['ref']);
add_comment_meta($comment_id, ‘ref’, $ref, false);
}}
add_action (‘comment_post’, ‘add_comment_meta_values’, 1);

Display Value in Comments

function my_comments_callback( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;?>
<li <?php comment_class(); ?> id=”li-comment-<?php comment_ID(); ?>”>
<article id=”comment-<?php comment_ID(); ?>” class=”comment”>
<p><?php echo “Authors Country : “.get_comment_meta( $comment->comment_ID, ‘country’, true ); ?></p>
<p><?php echo “Old Profession : “.get_comment_meta( $comment->comment_ID, ‘oldpro’, true ); ?></p>
<p><?php echo “Reference : “.get_comment_meta( $comment->comment_ID, ‘ref’, true ); ?></p>
<div class=”comment-content”><?php comment_text(); ?></div>
<div class=”reply”>
<?php comment_reply_link( array_merge( $args, array( ‘reply_text’ => __( ‘Reply <span>&darr;</span>’, ‘twentyeleven’ ), ‘depth’ => $depth, ‘max_depth’ => $args['max_depth'] ) ) ); ?>
</div>
</article>
</li>
<?php
}

Create a Callback for Displaying Comments

In the Twenty Eleven theme in comments.php you will see a line:

wp_list_comments( array( 'callback' => 'twentyeleven_comment' ) );

This we will change to:

wp_list_comments( array( 'callback' => 'my_comments_callback' ) );

So the function my_comments_callback will be called for each post.

Display Custom Fields Value in Admin

Use Codepress Admin Columns plugin to Display your custom field value in admin.




Untitled-3

Find out what the exact time is right now at any of 7 million locations

About Time.is

On Time.is you can:

  • Find out what the exact time is right now at any of 7 million locations around the world
  • Check the accuracy of your clock
  • Compare time at different locations

You will also find:

  • Calendar
  • Sunrise and sunset times
  • Information about which time zone a location belongs to
  • Information about today’s holidays and observances
  • Latitudes and longitudes
  • Integrated, full screen Google Maps
  • Population numbers
  • Key information about every country in the world

Time.is is friendly to mobile devices. It uses minimal bandwidth and the design is adapted to small screens.