Showing posts with label Wordpress Shopping cart. Show all posts
Showing posts with label Wordpress Shopping cart. Show all posts

Wordpress Dropdown Category Ajax Search

WordPress Drop down Category Ajax Search


Today Discussed wordpress dropdown category list ajax search without plugin and create shortcodes follows briefly discussed. normally any search field or any one task mostly used plugin activate list of more then plugin this the wordpress large file and buy the plugin. So just avoid plugin hardcode this wordpress is category list ajax search follows code.

Wordpress Dropdown Category Ajax Search
Wordpress Dropdown Category Ajax Search


shortcodes.php

function ajax_filter_search($atts, $content = null) {
    extract(shortcode_atts(array(
  'post_type'    => AFSAdmin::afs_retrieve('_general_post_type'),
  'post_tax'     => AFSAdmin::afs_retrieve('_general_post_taxonomy'),
  'posts_per_page'  => AFSAdmin::afs_retrieve('_general_posts_per_page'),
  'filter_type'   => '',
  'filter_by'     => '',
  'filter_months'    => '',
  'filter_years'    => '',
  'filter_withPDF'   => '',
  'offset'     => 0,
    ), $atts));

ajax filter search what ever search stored array format year month and pdf taxnonmy etc.,  and included functions and follows code.

if($post_type == '') { } else { $afs_args .=' post_type="'.$post_type.'" '; }
 if($posts_per_page == '') { } else { $afs_args .=' posts_per_page="'.$posts_per_page.'" '; }
 if($filter_by == '') { } else { $afs_args .=' filter_by="'.$filter_by.'" '; }
 if($filter_months == '') { } else { $afs_args .=' filter_months="'.$filter_months.'" '; }
 if($filter_years == '') { } else { $afs_args .=' filter_years="'.$filter_years.'" '; }
 if($filter_withPDF == '') { } else { $afs_args .=' filter_withPDF="'.$filter_withPDF.'" '; }
 if($offset == '') { } else { $afs_args .=' offset="'.$offset.'" '; }
  
 if($filter_type == '') { 
  $all='all'; 
  $filter_type_count = 999;
 } else { 
  $afs_args .=' filter_type="'.$filter_type.'" '; 
  $all=$filter_type;
  $filter_type_array = explode(',',$filter_type);
  $filter_type_count = count($filter_type_array);
 }
  
 $text = '';
 $i = 1;
ajax filter conditions check else and true or false conditions check and then show this html code included same php format follows.

$text .= '<div id="afs-wrapper">';
 $text .= ' <div class="press-releases">';
 $text .= '  <form id="newsForm">';
 $text .= '   <div class="row">';
 
 
 $text .= '    <div class="col-xs-1TableRowItem2">';
 
   $text .= '       <label for="category"><strong>Display:&nbsp;</strong></label>';
   $text .= '       <select name="category">';
   $text .= '        <option value="all">All</option>';
             $terms = get_terms($taxonomy, $args = array('orderby'=>'id') );
             if($terms) {
             
              foreach($terms as $term) {
               if(isset($filter_type_array)) {
                if(in_array($term->slug,$filter_type_array)) {
                 if($term->name == 'Uncategorized') { continue; }
                 $text .= '<option value="'.$term->slug.'">'.$term->name.'</option>';
                }
               } else {
                if($term->name == 'Uncategorized') { continue; }
                 $text .= '<option value="'.$term->slug.'">'.$term->name.'</option>';
               }
              }
             }
   $text .= '       </select>';
   $text .= '      </div>';
   $text .= '     </div>';
  }
  } 
 
function.php

if (!function_exists('myplugin_ajaxurl')) {
 add_action('wp_head', 'myplugin_ajaxurl');
 
 function myplugin_ajaxurl() {
 
    echo '<script type="text/javascript">
      var ajaxurl = "' . admin_url('admin-ajax.php') . '";
      var scriptpath = "' . site_url() . '";
    </script>';
 }
}

if (!function_exists('my_action_callback')) {
 // Ajax call to sort PRs
 function my_action_callback() {  
 
  // Get the values:
  $post_type  = AFSAdmin::afs_retrieve('_general_post_type');
  $posts_per_page = AFSAdmin::afs_retrieve('_general_posts_per_page');
  $filter_type  = $_POST['filingType'];
  $filter_by   = $_POST['filterBy'];
  $filter_months  = $_POST['filterMonths'];
  $filter_years  = $_POST['filterYears'];
  $filter_withPDF = $_POST['withPDF'];
 
  $offset    = $_POST['page'];
  
  echo do_shortcode('[afs_feed post_type="'.$post_type.'" posts_per_page="'.$posts_per_page.'" offset="'.$offset.'" filter_type="'.$filter_type.'" filter_by="'.$filter_by.'" filter_months="'.$filter_months.'" filter_years="'.$filter_years.'" filter_withPDF="'.$filter_withPDF.'"]');
 
  exit;
 
 }
 
 add_action('wp_ajax_my_action', 'my_action_callback');
 add_action('wp_ajax_nopriv_my_action', 'my_action_callback');
}

/*******************************************************************
* AJAX IN ADMIN
********************************************************************/
if (!function_exists('get_selected_taxonomy')) {
 // Ajax call to get taxnomy values
 function get_selected_taxonomy() {  
 
  // Get the values:
  $cur_post_tax = AFSAdmin::afs_retrieve('_general_post_taxonomy');
  $post_type   = $_POST['option'];
  
  $taxonomy_objects = get_object_taxonomies($post_type, 'objects');
  
  if($taxonomy_objects) {
   foreach($taxonomy_objects as $tax) {
    $sel = '';
    if($tax->name == 'post_format') {
     continue;
    } else {
     if($tax->name == $cur_post_tax) { $sel = 'selected="selected"'; }
     echo '<option value="'.$tax->name.'" '.$sel.'>'.$tax->label.'</option>';
    }
   } 
  } else {
   echo '<option value="none" '.$sel.'>None</option>';
  }
 
  exit;
 
 }
 
 add_action('wp_ajax_get_selected', 'get_selected_taxonomy');
 add_action('wp_ajax_nopriv_get_selected', 'get_selected_taxonomy');
}

/*add_action( 'admin_footer', 'my_action_javascript' ); // Write our JS below here

function my_action_javascript() { ?>
 <script type="text/javascript" >
 jQuery(document).ready(function($) {
  
  $('#afs-form input#submit').on({
   click: function(){
    
    //return false;
    
   }
  });
  
  var data = {
   'action': 'my_action',
   'whatever': 1234
  };

  // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
  jQuery.post(ajaxurl, data, function(response) {
   console.log('Got this from the server: ' + response);
  });
 });
 </script> <?php
}*/
?>

Using AJAX With PHP on Your WordPress Site Without a Plugin

Using AJAX With PHP on Your WordPress Site Without a Plugin

Today Discussed Using Ajax with php on your wordpress site without a plugin. It enables websites to load content into various elements without refreshing the page. This may not seem like a huge feature list but it allows us to do so much.

Using AJAX With PHP on Your WordPress Site Without a Plugin
Using AJAX With PHP on Your WordPress Site Without a Plugin

How AJAX Works

  • You specify information to send
  • You configure the Ajax call
  • The XMLHttpRequest object is used to send the data to the server
  • The server response is returned and can be used by your JS code
  • Ajax is most commonly used through jQuery wrapper functions. If you would like to learn Ajax without jQuery I suggest taking a look at the W3Schools Tutorial. Here we’ll be looking at the jQuery functions only.

add_action( 'wp_enqueue_scripts', 'ajax_test_enqueue_scripts' );
function ajax_test_enqueue_scripts() {
wp_enqueue_script( 'test', plugins_url( '/test.js', __FILE__ ), array('jquery'), '1.0', true );
}

Creating the Ajax Call

jQuery(document).ready( function($) {

$.ajax({
url: "http://yourwebsite.com",
success: function( data ) {
alert( 'Your home page has ' + $(data).find('div').length + ' div elements.');
}
})


})

Storing And Displaying Our Data

We’ll be storing the number of “loves” a post has received in a meta field in the database, let’s call it post_love. The value of this field will be displayed under each post in the single page, here’s how:



add_filter( 'the_content', 'post_love_display', 99 );
function post_love_display( $content ) {
$love_text = '';

if ( is_single() ) {

$love = get_post_meta( get_the_ID(), 'post_love', true );
$love = ( empty( $love ) ) ? 0 : $love;

$love_text = '<p class="love-received"><a class="love-button" href="#" data-id="' . get_the_ID() . '">give love</a><span id="love-count">' . $love . '</span></p>';

}

return $content . $love_text;

}

Top 5 Most Popular WordPress Plugin

Top 5 Most Popular WordPress Plugin

Most Popular Plugin The following contains a list of the top 5 most popular WordPress Plugins that have been detected by WordPress Theme.

1. Yoast WordPress SEO Plugin

Yoast WordPress SEO
Yoast WordPress SEO

Easily optimize your WordPress site with one plugin and Real time content analysis functionality and many more features to streamline your site.a Premium Yoast seo plugin for even same but more features and support seo. Read More


2.Contact Form 7
Contact Form7
Contact Form7


Contact Form 7 can manage multiple contact forms, plus you can customize the form and the mail contents flexibly with simple markup. The form supports Ajax-powered submitting, CAPTCHA, Akismet spam filtering and so on.  Read More


3.All In One SEO Pack


All In One SEO
All In One SEO
The most downloaded plugin for WordPress (almost 30 million downloads). Use All in One SEO Pack to automatically optimize your site for Search Engines Read More

4. Js_composer

Js_Composer
Js_Composer

Visual Composer is the #1 best selling frontend and beackend drag and drop page builder Read More

5.Woocommerce

Woocommerce
Woocommerce

Wordpress Woocommerce site Your page selling product and more selling website very easily product added and cart page check out in your site.  Read More

Wordpress Shopping cart Installation

How to Use WP Shopping Cart


Wordpress Shopping cart
Wordpress Shopping cart


Add the shopping cart to your theme.


Copy wp-shopping-cart.php to your theme directory. Call the shopping cart in your functions.php file: Normal PHP shopping car

require_once('wp-shopping-cart.php');

Configure your settings.

In the wp-shopping-cart.php file, replace these variables with your information:
$paypal_account - Your PayPal email address
$cart_icon - An icon for your shopping cart link, if you have one
$url_store - The URL of your store
$url_cart - The URL of your shopping cart
$url_update - The meta info/URL when the cart is updated
$url_success - The meta info/URL when the checkout is successful
Shipping variables - Based on shopping cart subtotal value

 Create product pages.

Create pages for your products, and use the [add_to_cart] shortcode to create links.

Shortcode variables:
product="PRODUCT NAME"
price="X.XX"
options="TITLE=OPTION 1|OPTION 2|OPTION 3" (Not required. Limit 1 set of options.)
sold="SOLD OUT MESSAGE"

Example:
[add_to_cart product="T-Shirt" price="20" options="Size=Small|Med|Large"]

Create a shopping cart page.

Create a shopping cart page, and use the [checkout_cart] shortcode to embed a cart.


 Add a link to the cart.

Add a link to the cart anywhere on your site using the [checkout_cart_link] shortcode or <?php echo checkout_cart_link(); ?>.

Another Method

WP Shopping Cart Installation


  • Unzip and Upload the folder “wordpress-paypal-shopping-cart” to the “/wp-content/plugins/” directory.
  • Activate this Plugin
  • Go to settings and configure the options your peyment method paypal email,shopping cart and return url etc
  • Use the shortcode to add a product a post or page where you want it to appear

WP Shopping Cart

To add the ‘Add to Cart’ button simply insert the following shortcode to a post or page next to the product description:

[wp_cart_button name="PRODUCT-NAME" price="PRODUCT-PRICE"]

Replace PRODUCT-NAME and PRODUCT-PRICE with the actual name and price.

Here is an example usage of the shortcode:

[wp_cart_button name="Test Product" price="19.95"]
To add the shopping cart to a post or page, insert the following shortcode to a post or page.

[show_wp_shopping_cart]
Using Button and Cart Form a template File

To Add 'Add Cart Button' from template.php file use this code:
<?php echo print_wp_cart_button_for_product('PRODUCT-NAME', PRODUCT-PRICE); ?>
<?php echo print_wp_cart_button_for_product('wordpress', 7.50); ?>
To add the shopping cart to the sidebar, simply use the widget from the widgets menu or add the following line to your sidebar template file where you want the shopping cart to appear

<?php echo print_wp_shopping_cart() ?>