All posts by Sivakumar

Load all href images into a dialog Popup from Particular content

Step :Load the anchor tag href images into a dialog Popup

Need to include jquery.js, jquery-ui.js and jquery-ui.css

I have included like below.

<script src=”//code.jquery.com/jquery-1.10.2.js”></script>
<script src=”//code.jquery.com/ui/1.11.4/jquery-ui.js”></script>
<link href=”https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.css” rel=”stylesheet” type=”text/css” />

<script type="text/javascript">
 jQuery('.entry-content a').each(function() {
 var $link = $(this);
 var $dialog = jQuery('<img src="' + $link.attr('href') + '" />')
	.dialog({
		autoOpen: false,
		resizeable: false,
		modal: true,
		width: 1000,
		closeOnEscape: true,
		dialogClass: 'zoom',
		position: { my: 'top', at: 'top+2400' },
		zIndex: 9999
	 });
         $link.click(function() {
	$dialog.dialog('open');
	return false;
	});
 });
</script>

Add Custom Post Meta Field For All Posts

Step1: Add Custom Meta Function

function add_custom_meta_box()
{
    add_meta_box("instruction-meta-box", "Instruction Field", "custom_meta_box_post", "post", "normal", "high", null);
}
 
add_action("add_meta_boxes", "add_custom_meta_box");

 

Step2: Create Add Custom Meta Field Function

function custom_meta_box_post($object)
{
    wp_nonce_field(basename(__FILE__), "meta-box-nonce");
 
    ?>
        <div>
            <textarea name="meta-box-text" style="width: 1000px;height: 200px;"><?php echo get_post_meta($object->ID, "meta-box-text", true); ?></textarea>
        </div>
    <?php  
}

 

Step3: Save the Custom Meta Field Data Function

function save_custom_meta_box($post_id, $post, $update)
{
    if (!isset($_POST["meta-box-nonce"]) || !wp_verify_nonce($_POST["meta-box-nonce"], basename(__FILE__)))
        return $post_id;
 
    if(!current_user_can("edit_post", $post_id))
        return $post_id;
 
    if(defined("DOING_AUTOSAVE") && DOING_AUTOSAVE)
        return $post_id;
 
    $slug = "post";
    if($slug != $post->post_type)
        return $post_id;
 
    $meta_box_text_value = "";
    $meta_box_dropdown_value = "";
    $meta_box_checkbox_value = "";
 
    if(isset($_POST["meta-box-text"]))
    {
        $meta_box_text_value = $_POST["meta-box-text"];
    }   
    update_post_meta($post_id, "meta-box-text", $meta_box_text_value);
}
 
add_action("save_post", "save_custom_meta_box", 10, 3);

JQuery – Find() – this – show and hide Process

<a class='clickclick'>Screenshots
   <div class='screen-pop'>
      <div class='screen-wrap'>
          <img src="/images/example.jpg">
      </div>
      <p class='close-window'></p>
   </div>											
</a>
<script type="text/javascript">
// show	
$('.clickclick').click(function() {
   $(this).find(".screen-pop").show();
});
// hide	
$('#lightbox').click(function() {
   $(".screen-pop").hide();							
});
</script>

Getting the Totals of the Cart

 

Step1: Getting the SubTotal of the Cart:

<?php Mage::getSingleton('checkout/session')->getQuote()->getSubtotal(); ?>

 

Step2: Getting the GrandTotal of the Cart:

<?php 
     $totals = Mage::getSingleton('checkout/session')->getQuote()->getTotals(); //Total object			
     $grandtotal = round($totals["grand_total"]->getValue());//Grandtotal value 
     echo $formattedPrice = Mage::helper('core')->currency($grandtotal , true, false);
?>