Advertisement
Guest User

Untitled

a guest
Sep 17th, 2010
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 39.65 KB | None | 0 0
  1. <?php
  2. if(!isset($_SESSION))
  3. {
  4.     session_start();
  5. }  
  6.  
  7. define('WP_ESTORE_FOLDER', dirname(plugin_basename(__FILE__)));
  8. $eStore_url = WP_PLUGIN_URL.'/'.WP_ESTORE_FOLDER;
  9. if ($_SERVER["HTTPS"] == "on")
  10. {
  11.     $eStore_url = str_replace("http:","https:",$eStore_url);
  12. }
  13. define('WP_ESTORE_URL', $eStore_url);
  14. define('WP_ESTORE_LIB_URL', WP_ESTORE_URL.'/lib');
  15. define('WP_ESTORE_IMAGE_URL', WP_ESTORE_URL.'/images');
  16.  
  17. global $wpdb;
  18. define('WP_ESTORE_PRODUCTS_TABLE_NAME', $wpdb->prefix . "wp_eStore_tbl");
  19. define('WP_ESTORE_CUSTOMER_TABLE_NAME', $wpdb->prefix . "wp_eStore_customer_tbl");
  20. define('WP_ESTORE_CATEGORY_TABLE_NAME', $wpdb->prefix . "wp_eStore_cat_tbl");
  21. define('WP_ESTORE_CATEGORY_RELATIONS_TABLE_NAME', $wpdb->prefix . "wp_eStore_cat_prod_rel_tbl");
  22. define('PAYPAL_LIVE_URL', "https://www.paypal.com/cgi-bin/webscr");
  23. define('PAYPAL_SANDBOX_URL', "https://www.sandbox.paypal.com/cgi-bin/webscr");
  24.  
  25. $addcart_eStore = get_option('addToCartButtonName');
  26. if (!$addcart_eStore || ($addcart_eStore == '') )
  27.     $addcart_eStore = 'Add to Cart';
  28. define('WP_ESTORE_ADD_CART_BUTTON', $addcart_eStore);
  29. define('WP_ESTORE_CURRENCY_SYMBOL', get_option('cart_currency_symbol'));
  30.  
  31. $soldOutImage = get_option('soldOutImage');
  32. if (empty($soldOutImage)) $soldOutImage = WP_ESTORE_URL.'/images/sold_out.png';
  33. define('WP_ESTORE_SOLD_OUT_IMAGE', $soldOutImage);
  34.  
  35. //includes
  36. $cart_language = get_option('eStore_cart_language');
  37. if (!empty($cart_language))
  38.     $language_file = "languages/".$cart_language;
  39. else
  40.     $language_file = "languages/eng.php";
  41. include_once($language_file);
  42. include_once('eStore_misc_functions.php');
  43. include_once('eStore_cart.php');
  44. include_once('eStore_includes2.php');
  45. include_once('eStore_includes3.php');
  46. include_once('email.php');
  47. include_once('eStore_discount_calc.php');
  48.  
  49. function eStore_sale_counter($atts) {
  50.     extract(shortcode_atts(array(
  51.         'id' => 'no id',
  52.     ), $atts));
  53.     return eStore_get_sale_counter($id);
  54. }
  55.  
  56. function eStore_remaining_copies_counter($atts) {
  57.     extract(shortcode_atts(array(
  58.         'id' => 'no id',
  59.     ), $atts));
  60.     return eStore_get_remaining_copies_counter($id);
  61. }
  62.  
  63. function eStore_download_now_button($atts) {
  64.     extract(shortcode_atts(array(
  65.         'id' => 'no id',
  66.     ), $atts));
  67.     return eStore_show_download_now_button($id);
  68. }
  69.  
  70. function eStore_download_now_button_fancy($atts) {
  71.     extract(shortcode_atts(array(
  72.         'id' => 'no id',
  73.     ), $atts));
  74.     return show_product_fancy_style($id,$button_type=4);
  75. }
  76.  
  77. function eStore_download_now_button_fancy_no_price_handler($atts) {
  78.     extract(shortcode_atts(array(
  79.         'id' => 'no id',
  80.     ), $atts));
  81.     return show_download_now_fancy_no_price($id);
  82. }
  83.  
  84. function eStore_fancy1($atts) {
  85.     extract(shortcode_atts(array(
  86.         'id' => 'no id',
  87.     ), $atts));
  88.     return show_product_fancy_style($id);
  89. }
  90.  
  91. function eStore_fancy2($atts) {
  92.     extract(shortcode_atts(array(
  93.         'id' => 'no id',
  94.     ), $atts));
  95.     return show_product_fancy_style2($id);
  96. }
  97.  
  98. function eStore_buy_now_fancy($atts) {
  99.     extract(shortcode_atts(array(
  100.         'id' => 'no id',
  101.     ), $atts));
  102.     return show_product_fancy_style($id,$button_type=2);
  103. }
  104.  
  105. function eStore_subscribe_fancy($atts) {
  106.     extract(shortcode_atts(array(
  107.         'id' => 'no id',
  108.     ), $atts));
  109.     return show_product_fancy_style($id,$button_type=3);
  110. }
  111.  
  112. function wp_estore_display_category_fancy($atts)
  113. {
  114.     extract(shortcode_atts(array(
  115.         'id' => 'no id',
  116.     ), $atts));
  117.     return show_category_stylish($id);
  118. }
  119.  
  120. function wp_eStore_buy_now_custom_button_handler($atts)
  121. {
  122.     extract(shortcode_atts(array(
  123.         'id' => 'no id',
  124.         'button' => 'Buy Now',
  125.     ), $atts));
  126.     return print_eStore_buy_now_button($id,$button);
  127. }
  128.  
  129. function wp_eStore_members_purchase_history_handler($atts)
  130. {  
  131.     return eStore_show_members_purchase_history();
  132. }
  133.  
  134. function wp_estore_display_categories_fancy()
  135. {
  136.     return show_all_categories_stylish();
  137. }
  138.  
  139. function wp_digi_cart_show($content)
  140. {
  141.     if (strpos($content, "<!--show-wp-cart-for-digital-products-->") !== FALSE)
  142.     {
  143.         if (digi_cart_not_empty())
  144.         {
  145.             $content = preg_replace('/<p>\s*<!--(.*)-->\s*<\/p>/i', "<!--$1-->", $content);
  146.             $matchingText = '<!--show-wp-cart-for-digital-products-->';
  147.             $replacementText = print_wp_digi_cart();
  148.             $content = str_replace($matchingText, $replacementText, $content);
  149.         }
  150.     }
  151.     return $content;
  152. }
  153. function filter_wp_digi_cart_always_show($content)
  154. {
  155.     if (strpos($content, "<!--always-show-wp-cart-->") !== FALSE)
  156.     {
  157.         $content = preg_replace('/<p>\s*<!--(.*)-->\s*<\/p>/i', "<!--$1-->", $content);
  158.         $matchingText = '<!--always-show-wp-cart-->';
  159.         $replacementText = wp_digi_cart_always_show();
  160.         $content = str_replace($matchingText, $replacementText, $content);
  161.     }
  162.     return $content;
  163. }
  164. function eStore_shopping_cart()
  165. {  
  166.     if (digi_cart_not_empty())
  167.     {
  168.         return eStore_shopping_cart_multiple_gateway();
  169.     }
  170.     return;
  171. }
  172.  
  173. function wp_digi_cart_always_show()
  174. {
  175.     if (digi_cart_not_empty())
  176.     {
  177.         $output = eStore_shopping_cart_multiple_gateway();
  178.     }
  179.     else
  180.     {
  181.         $title = get_option('wp_cart_title');
  182.         if(empty($title))
  183.         {
  184.             $title = "Your Shopping Cart";
  185.         }
  186.         $output .= '<a name="wp_cart_anchor"></a>';
  187.         $output .= '<div class="shopping_cart" style=" padding: 5px;">';
  188.         if (!get_option('eStore_shopping_cart_image_hide'))
  189.         {
  190.             $output .= "<input type='image' src='".WP_ESTORE_URL."/images/shopping_cart_icon.gif' value='Shopping Cart' title='Shopping Cart' />";
  191.         }
  192.         $output .= '<h2>';
  193.         $output .= $title;
  194.         $output .= '</h2>';
  195.         $output .= eStore_shopping_cart_multiple_gateway();
  196.         $output .= '</div>';
  197.     }
  198.     return $output;
  199. }
  200. function eStore_shopping_cart_fancy1_when_not_empty()
  201. {
  202.     $output = "";
  203.     if (digi_cart_not_empty())
  204.     {
  205.         $output = eStore_shopping_cart_fancy1();
  206.     }  
  207.     return $output;
  208. }
  209. function wp_estore_products($content)
  210. {
  211.     if (strpos($content, "<!--show-wp-cart-products-table-->") !== FALSE)
  212.     {
  213.             $content = preg_replace('/<p>\s*<!--(.*)-->\s*<\/p>/i', "<!--$1-->", $content);
  214.             $matchingText = '<!--show-wp-cart-products-table-->';
  215.             $replacementText = wp_estore_products_table();
  216.             $content = str_replace($matchingText, $replacementText, $content);
  217.     }
  218.     return $content;
  219. }
  220.  
  221. function eStore_cart_when_not_empty()
  222. {
  223.     if (digi_cart_not_empty())
  224.     {
  225.         $output = print_wp_digi_cart();
  226.     }
  227.     return $output;
  228. }
  229.  
  230. function filter_eStore_transaction_result($content)
  231. {
  232.         $pattern = '#\[wp_eStore_transaction_result:end]#';
  233.         preg_match_all ($pattern, $content, $matches);
  234.  
  235.         foreach ($matches[0] as $match)
  236.         {
  237.             $replacement = eStore_display_transaction_result();
  238.             $content = str_replace ($match, $replacement, $content);
  239.         }
  240.         return $content;
  241. }
  242. function eStore_display_all_products_stylish($content)
  243. {
  244.         $pattern = '#\[wp_eStore_all_products_stylish:end]#';
  245.         preg_match_all ($pattern, $content, $matches);
  246.  
  247.         foreach ($matches[0] as $match)
  248.         {
  249.             $replacement = eStore_print_all_products_stylish();
  250.             $content = str_replace ($match, $replacement, $content);
  251.         }
  252.         return $content;
  253. }
  254. function eStore_display_all_products_stylish2($content)
  255. {
  256.         $pattern = '#\[wp_eStore_all_products_stylish2:end]#';
  257.         preg_match_all ($pattern, $content, $matches);
  258.  
  259.         foreach ($matches[0] as $match)
  260.         {
  261.             $replacement = eStore_print_all_products_stylish('2');
  262.             $content = str_replace ($match, $replacement, $content);
  263.         }
  264.         return $content;
  265. }
  266.  
  267. if(isset($_POST['mc_gross']))
  268. {
  269.     reset_eStore_cart();   
  270.     eStore_collect_payment_data();    
  271. }
  272.  
  273. if(isset($_GET["mc_gross"]))
  274. {
  275.     $mc_gross = $_GET["mc_gross"];
  276.     if ($mc_gross > 0)
  277.     {
  278.         reset_eStore_cart();
  279.         header('Location: ' . get_option('cart_return_from_paypal_url'));
  280.     }
  281. }
  282.  
  283. if(isset($_GET["merchant_return_link"]))
  284. {
  285.     $eStore_return_link = $_GET["merchant_return_link"];
  286.     if (!empty($eStore_return_link))
  287.     {
  288.         reset_eStore_cart();
  289.         header('Location: ' . get_option('cart_return_from_paypal_url'));
  290.     }
  291. }
  292.  
  293. function reset_eStore_cart()
  294. {
  295.     if(isset($_SESSION['eStore_cart']))
  296.     {
  297.         $products = $_SESSION['eStore_cart'];
  298.         foreach ($products as $key => $item)
  299.         {
  300.             if (!empty($item['name']))
  301.                 unset($products[$key]);
  302.         }
  303.         unset($_SESSION['discount_applied_once']);
  304.         unset($_SESSION['coupon_code']);
  305.         unset($_SESSION['eStore_last_action_msg']);
  306.         $_SESSION['eStore_cart'] = $products;
  307.     }
  308. }
  309.  
  310. if ($_POST['reset_eStore_cart'])
  311. {
  312.     reset_eStore_cart();
  313. }
  314.  
  315. if ($_POST['addcart_eStore'])
  316. {
  317.     setcookie("cart_in_use","true",time()+21600,"/");  
  318.     unset($_SESSION['eStore_last_action_msg']);
  319.     $count = 1;
  320.     $products = $_SESSION['eStore_cart'];
  321.  
  322.     if (is_array($products))
  323.     {
  324.         foreach ($products as $key => $item)
  325.         {
  326.             if ($item['name'] == stripslashes($_POST['product']))
  327.             {
  328.                 $req_qty = $item['quantity']+$_POST['add_qty'];
  329.                 $update_quantity = is_quantity_availabe($item['item_number'],$req_qty);
  330.  
  331.                 $count += $item['quantity'];
  332.                 if ($update_quantity)
  333.                 {
  334.                     $item['quantity'] = $item['quantity'] + $_POST['add_qty'];
  335.                     unset($products[$key]);
  336.                     array_push($products, $item);
  337.                 }
  338.             }
  339.         }
  340.     }
  341.     else
  342.     {
  343.         $products = array();
  344.     }
  345.  
  346.     if ($count == 1)
  347.     {
  348.         //echo "<br />Request-> Item:".$_POST['item_number']." Qty:".$_POST['add_qty'];
  349.         $quantity_available = is_quantity_availabe($_POST['item_number'],$_POST['add_qty']);
  350.         if (!$quantity_available)
  351.         {
  352.             //Requested qty not available
  353.             $_POST['add_qty'] = 1; //Add one by default
  354.         }
  355.        
  356.         if (!empty($_POST[$_POST['product']])){
  357.             $price = $_POST[$_POST['product']];
  358.         }
  359.         else if (isset($_POST['custom_price'])){
  360.             global$wpdb;
  361.             $products_table_name = WP_ESTORE_PRODUCTS_TABLE_NAME;
  362.             $id = $_POST['item_number'];
  363.             $retrieved_product = $wpdb->get_row("SELECT * FROM $products_table_name WHERE id = '$id'", OBJECT);
  364.             if($_POST['custom_price'] < $retrieved_product->price){
  365.                 $price = $retrieved_product->price;
  366.                 $currSymbol = get_option('cart_currency_symbol');
  367.                 $_SESSION['eStore_last_action_msg'] = '<p style="color: red;">'.WP_ESTORE_MINIMUM_PRICE_YOU_CAN_ENTER.$currSymbol.$retrieved_product->price.'</p>';
  368.             }          
  369.             else{
  370.                 $price = $_POST['custom_price'];
  371.             }
  372.         }
  373.         else{
  374.             $price = $_POST['price'];
  375.         }
  376.         $product = array('name' => stripslashes($_POST['product']), 'price' => $price, 'quantity' => $_POST['add_qty'], 'shipping' => $_POST['shipping'], 'item_number' => $_POST['item_number'], 'cartLink' => $_POST['cartLink']);
  377.         array_push($products, $product);
  378.         //$_SESSION['eStore_last_action_msg'] = '<p style="color: #30D062;">'.ESTORE_ITEM_ADDED.'</p>';    
  379.     }
  380.  
  381.     sort($products);
  382.     $_SESSION['eStore_cart'] = $products;
  383.  
  384.     if (get_option('eStore_auto_checkout_redirection'))
  385.     {
  386.         $checkout_url = eStore_get_checkout_url();
  387.         $redirection_parameter = 'Location: '.$checkout_url;
  388.         header($redirection_parameter);
  389.         exit;
  390.     }
  391.     eStore_redirect_if_using_anchor();
  392. }
  393. else if ($_POST['eStore_cquantity'])
  394. {
  395.     unset($_SESSION['eStore_last_action_msg']);
  396.     if ($_SESSION['discount_applied_once'] == 1)
  397.     {
  398.         reset_eStore_cart();
  399.     }
  400.     else
  401.     {
  402.         $products = $_SESSION['eStore_cart'];
  403.         foreach ($products as $key => $item)
  404.         {
  405.             if (($item['name'] == stripslashes($_POST['product'])) && $_POST['quantity'])
  406.             {
  407.                 $update_quantity = is_quantity_availabe($item['item_number'],$_POST['quantity']);
  408.                 if ($update_quantity)
  409.                 {
  410.                     $item['quantity'] = $_POST['quantity'];
  411.                     unset($products[$key]);
  412.                     array_push($products, $item);
  413.                 }
  414.             }
  415.             else if (($item['name'] == stripslashes($_POST['product'])) && !$_POST['quantity'])
  416.                 unset($products[$key]);
  417.         }
  418.         sort($products);
  419.         $_SESSION['eStore_cart'] = $products;
  420.        
  421.         eStore_redirect_if_using_anchor();
  422.     }    
  423. }
  424. else if ($_POST['eStore_delcart'])
  425. {
  426.     unset($_SESSION['eStore_last_action_msg']);
  427.     if ($_SESSION['discount_applied_once'] == 1)
  428.     {
  429.         reset_eStore_cart();
  430.     }
  431.        
  432.     $products = $_SESSION['eStore_cart'];
  433.     foreach ($products as $key => $item)
  434.     {
  435.         if ($item['name'] == stripslashes($_POST['product']))
  436.             unset($products[$key]);
  437.     }
  438.     $_SESSION['eStore_cart'] = $products;
  439.  
  440.     eStore_redirect_if_using_anchor();
  441. }
  442. if ($_POST['eStore_apply_discount'])
  443. {
  444.     $coupon = $_POST['coupon_code'];
  445.     eStore_apply_discount($coupon);
  446. }
  447.  
  448. if ($_POST['eStore_apply_aff_id'])
  449. {
  450.     if (function_exists('wp_aff_platform_install'))
  451.     {
  452.         record_click_for_eStore_cart($_POST['estore_aff_id']); 
  453.         $_SESSION['eStore_last_action_msg'] = '<p style="color: #30D062;">'.ESTORE_AFFILIATE_ID_SET.'</p>';
  454.        
  455.         if (get_option('eStore_aff_link_coupon_aff_id') == 1)
  456.         {
  457.             eStore_apply_discount($_POST['estore_aff_id']);        
  458.         }      
  459.     }
  460.     else
  461.     {
  462.         $_SESSION['eStore_last_action_msg'] = '<p style="color: red;">'.ESTORE_AFFILIATE_PLUGIN_INACTIVE.'</p>';
  463.     }
  464. }
  465.  
  466. if ($_POST['eStore_download_now_button'])
  467. {
  468.     $product_id = $_POST['download_now_product_id'];
  469.     $download_link = eStore_generate_download_link1($product_id);
  470.     $redirection_parameter = 'Location: '.$download_link;
  471.     header($redirection_parameter);
  472.     exit;
  473. }
  474.  
  475. if ($_POST['eStore_free_download'])
  476. {
  477.     $input_verified = true;
  478.     if (empty($_POST['cust_name']))
  479.     {
  480.         echo '<script type="text/javascript">alert("Please enter your name!")</script>';
  481.         $input_verified = false;
  482.     }
  483.     if (empty($_POST['cust_email']))
  484.     {
  485.         echo '<script type="text/javascript">alert("Please enter your email address!")</script>';
  486.         $input_verified = false;
  487.     }
  488.  
  489.     if ($input_verified)
  490.     {
  491.         $product_id = $_POST['free_download_product_id'];
  492.         $download_link = eStore_generate_download_link1($product_id);
  493.         if (eStore_send_free_download2($_POST['cust_name'], $_POST['cust_email'], $download_link))
  494.         {
  495.             // Update the Customer table
  496.             $emailaddress = $_POST['cust_email'];
  497.             $name_pieces = explode(' ', $_POST['cust_name']);
  498.             $firstname = $name_pieces[0];
  499.             if (!empty($name_pieces[1]))
  500.                $lastname = $name_pieces[1];
  501.  
  502.             global $wpdb;
  503.             $customer_table_name = WP_ESTORE_CUSTOMER_TABLE_NAME;
  504.             $ret_customer_db = $wpdb->get_results("SELECT * FROM $customer_table_name WHERE purchased_product_id = '$product_id'", OBJECT);
  505.             $entry_exists = false;
  506.             if ($ret_customer_db)
  507.             {
  508.                foreach ($ret_customer_db as $ret_customer_db)
  509.                {
  510.                    if ($ret_customer_db->email_address == $emailaddress)
  511.                    {
  512.                        $entry_exists = true;
  513.                    }
  514.                }
  515.             }
  516.             if (!$entry_exists)
  517.             {
  518.                 $clientdate = (date ("Y-m-d"));
  519.                 $txn_id = "Free Download";
  520.                 $sale_price = '0';
  521.                 $updatedb = "INSERT INTO $customer_table_name (first_name, last_name, email_address, purchased_product_id,txn_id,date,sale_amount) VALUES ('$firstname', '$lastname','$emailaddress','$product_id','$txn_id','$clientdate','$sale_price')";
  522.                 $results = $wpdb->query($updatedb);
  523.             }
  524.             echo '<script type="text/javascript">alert("Please check your inbox for the download link!")</script>';
  525.         }
  526.         else
  527.         {
  528.             echo '<script type="text/javascript">alert("Could not send the download link!")</script>';
  529.         }
  530.     }
  531. }
  532.  
  533. function eStore_apply_discount($coupon)
  534. {
  535.     if ($_SESSION['discount_applied_once'] != 1)
  536.     {        
  537.         $_SESSION['eStore_coupon_code'] = $coupon;
  538.         global $wpdb;
  539.         $coupon_table_name = $wpdb->prefix . "wp_eStore_coupon_tbl";
  540.         $ret_coupon = $wpdb->get_row("SELECT * FROM $coupon_table_name WHERE coupon_code = '$coupon'", OBJECT);
  541.         if ($ret_coupon)
  542.         {
  543.             $coupon_error = false;
  544.             if($ret_coupon->active!='Yes')
  545.             {
  546.                 $coupon_error = true;
  547.                 $_SESSION['eStore_last_action_msg'] = '<p style="color: red;">'.ESTORE_COUPON_NOT_ACTIVE.'</p>';
  548.             }
  549.             else if(!empty($ret_coupon->redemption_count) && $ret_coupon->redemption_count >= $ret_coupon->redemption_limit)
  550.             {
  551.                 $coupon_error = true;
  552.                 $_SESSION['eStore_last_action_msg'] = '<p style="color: red;">'.ESTORE_MAX_COUPON_USE.'</p>';
  553.             }
  554.  
  555.             if(!$coupon_error)
  556.             {
  557.                 if(empty($ret_coupon->value))
  558.                 {
  559.                     $discount_amount = $ret_coupon->discount_value;
  560.                     $discount_type = $ret_coupon->discount_type;
  561.                     $discount_total = 0;
  562.                     $products = $_SESSION['eStore_cart'];
  563.                     if ($discount_type == 0)
  564.                     {
  565.                         foreach ($products as $key => $item)
  566.                         {
  567.                             if ($item['price'] > 0)
  568.                             {
  569.                                 $item_discount = (($item['price']*$discount_amount)/100);                          
  570.                                 $discount_total = $discount_total + $item_discount*$item['quantity'];
  571.                                 $item['price'] = $item['price'] - $item_discount;
  572.                                 unset($products[$key]);
  573.                                 array_push($products, $item);
  574.                             }
  575.                             $_SESSION['discount_applied_once'] = 1;
  576.                         }
  577.                     }
  578.                     else
  579.                     {
  580.                         foreach ($products as $key => $item)
  581.                         {
  582.                             if (($item['price'] - $discount_amount)> 0)
  583.                             {
  584.                                 $discount_total = $discount_total + $discount_amount*$item['quantity'];
  585.                                 $item['price'] = ($item['price'] - $discount_amount);
  586.                                 unset($products[$key]);
  587.                                 array_push($products, $item);
  588.                             }
  589.                             $_SESSION['discount_applied_once'] = 1;
  590.                         }
  591.                     }
  592.                     $discount_total = round($discount_total, 2);
  593.                     $discount_total = number_format($discount_total, 2, '.', '');
  594.                     $_SESSION['eStore_last_action_msg'] = '<p style="color: #30D062;">'.ESTORE_TOTAL_DISCOUNT.WP_ESTORE_CURRENCY_SYMBOL.$discount_total.'</p>';
  595.                     sort($products);
  596.                     $_SESSION['eStore_cart'] = $products;
  597.                 }
  598.                 else
  599.                 {
  600.                     $discount_total = round(eStore_apply_cond_discount($ret_coupon),2);
  601.                     if($discount_total != 0)
  602.                     {
  603.                         $discount_total = number_format($discount_total, 2, '.', '');
  604.                         $_SESSION['discount_applied_once'] = 1;
  605.                         $_SESSION['eStore_last_action_msg'] = '<p style="color: #30D062;">'.ESTORE_TOTAL_DISCOUNT.WP_ESTORE_CURRENCY_SYMBOL.$discount_total.'</p>';
  606.                     }
  607.                     else if ($discount_total == -99)//ESTORE_DISCOUNT_FREE_SHIPPING
  608.                     {
  609.                         $_SESSION['discount_applied_once'] = 1;
  610.                         $_SESSION['eStore_last_action_msg'] = '<p style="color: #30D062;">'.ESTORE_TOTAL_DISCOUNT.$discount_total.'</p>';                      
  611.                     }
  612.                     else
  613.                     {
  614.                         $_SESSION['eStore_last_action_msg'] = '<p style="color: red;">'.ESTORE_COUPON_COND_NOT_MET.'</p>';
  615.                     }
  616.                 }
  617.             }//end apply discount
  618.         }
  619.         else
  620.         {
  621.             $_SESSION['eStore_last_action_msg'] = '<p style="color: red;">'.ESTORE_COUPON_INVALID.'</p>';
  622.         }
  623.     }
  624.     else
  625.     {
  626.         $_SESSION['eStore_last_action_msg'] = '<p style="color: red;">'.ESTORE_DISCOUNT_LIMIT.'</p>';
  627.     }  
  628. }
  629.  
  630. function eStore_redirect_if_using_anchor()
  631. {  
  632.     if (get_option('eStore_auto_cart_anchor'))
  633.     {
  634.         $anchor_name = digi_cart_current_page_url()."#wp_cart_anchor";
  635.         $redirection_parameter = 'Location: '.$anchor_name;
  636.         header($redirection_parameter);        
  637.     }      
  638. }
  639. function is_quantity_availabe($id,$requested_quantity)
  640. {
  641.     global $wpdb;
  642.     $products_table_name = WP_ESTORE_PRODUCTS_TABLE_NAME;
  643.     $ret_product = $wpdb->get_row("SELECT * FROM $products_table_name WHERE id = '$id'", OBJECT);
  644.     if (is_numeric ($ret_product->available_copies))
  645.     {
  646.         if ($ret_product->available_copies >= $requested_quantity)
  647.         {
  648.             //$_SESSION['eStore_last_action_msg'] = '<p style="color: #30D062;">'.ESTORE_QTY_UPDATED.'</p>';
  649.             return true;
  650.         }
  651.         else
  652.         {
  653.             $_SESSION['eStore_last_action_msg'] = '<p style="color: red;">'.ESTORE_QUANTITY_LIMIT_EXCEEDED.' '.ESTORE_AVAILABLE_QTY.': '.$ret_product->available_copies.'</p>';
  654.             return false;
  655.         }
  656.     }
  657.     else
  658.     {
  659.         //$_SESSION['eStore_last_action_msg'] = '<p style="color: #30D062;">'.ESTORE_QTY_UPDATED.'</p>';
  660.         return true;
  661.     }
  662. }
  663.  
  664. function print_wp_digi_cart()
  665. {
  666.     //return eStore_shopping_cart();
  667.     return eStore_shopping_cart_multiple_gateway();
  668. }
  669.  
  670. function aff_add_custom_field()
  671. {
  672.     $custom_field_val = eStore_get_custom_field_value();
  673.     $output = '<input type="hidden" name="custom" value="'.$custom_field_val.'" id="eStore_custom_values" />';
  674.     return  $output;
  675. }
  676. function eStore_get_custom_field_value()
  677. {
  678.     $output = '';
  679.     $_SESSION['eStore_custom_values']='';
  680.     if (!empty($_SESSION['ap_id']))
  681.     {
  682.         $name = 'ap_id';
  683.         $value = $_SESSION['ap_id'];
  684.         $custom_field_val = append_values_to_custom_field($name,$value);
  685.     }
  686.     else if (isset($_COOKIE['ap_id']))
  687.     {
  688.         $name = 'ap_id';
  689.         $value = $_COOKIE['ap_id'];
  690.         $custom_field_val = append_values_to_custom_field($name,$value);
  691.     }
  692.     if (!empty($_SESSION['eStore_coupon_code']))
  693.     {
  694.         $name = 'coupon';
  695.         $value = $_SESSION['eStore_coupon_code'];
  696.         $custom_field_val = append_values_to_custom_field($name,$value);
  697.     }
  698.     if (function_exists('wp_eMember_install'))
  699.     {  
  700.         global $auth;
  701.         $user_id = $auth->getUserInfo('member_id');
  702.         if (!empty($user_id))
  703.         {
  704.             $name = 'eMember_id';
  705.             $custom_field_val = append_values_to_custom_field($name,$user_id);
  706.         }
  707.     }  
  708.     return $custom_field_val;
  709. }
  710. function append_values_to_custom_field($name,$value)
  711. {
  712.     $custom_field_val = $_SESSION['eStore_custom_values'];
  713.     $new_val = $name.'='.$value;
  714.     if (empty($custom_field_val))
  715.     {
  716.         $custom_field_val = $new_val;
  717.     }
  718.     else
  719.     {
  720.         $custom_field_val = $custom_field_val.'&'.$new_val;
  721.     }
  722.     $_SESSION['eStore_custom_values'] = $custom_field_val;
  723.     return $custom_field_val;
  724. }
  725.  
  726. function print_wp_digi_cart_button($content)
  727. {
  728.         $pattern = '#\[wp_eStore:product_id:.+:end]#';
  729.         preg_match_all ($pattern, $content, $matches);
  730.  
  731.         foreach ($matches[0] as $match)
  732.         {
  733.             $pattern = '[wp_eStore:product_id:';
  734.             $m = str_replace ($pattern, '', $match);
  735.  
  736.             $pattern = ':end]';
  737.             $m = str_replace ($pattern, '', $m);
  738.  
  739.             $pieces = explode('|',$m);
  740.             $key = $pieces[0];
  741.  
  742.             if (sizeof($pieces) == 1)
  743.             {
  744.                 $replacement = get_button_code_for_product($key);
  745.                 $content = str_replace ($match, $replacement, $content);
  746.             }
  747.         }
  748.         return $content;
  749. }
  750.  
  751. function print_wp_digi_cart_button_for_product($id)
  752. {
  753.     $replacement = get_button_code_for_product($id);
  754.     return $replacement;
  755. }
  756.  
  757. function eStore_fancy_product_display($content)
  758. {
  759.         $pattern = '#\[wp_eStore_fancy:product_id:.+:end]#';
  760.         preg_match_all ($pattern, $content, $matches);
  761.  
  762.         foreach ($matches[0] as $match)
  763.         {
  764.             $pattern = '[wp_eStore_fancy:product_id:';
  765.             $m = str_replace ($pattern, '', $match);
  766.  
  767.             $pattern = ':end]';
  768.             $m = str_replace ($pattern, '', $m);
  769.  
  770.             $pieces = explode('|',$m);
  771.             $key = $pieces[0];
  772.  
  773.             if (sizeof($pieces) == 1)
  774.             {
  775.                 $replacement = show_product_fancy_style($key);
  776.                 $content = str_replace ($match, $replacement, $content);
  777.             }
  778.         }
  779.         return $content;
  780. }
  781.  
  782. function eStore_fancy_product_display2($content)
  783. {
  784.         $pattern = '#\[wp_eStore_fancy2:product_id:.+:end]#';
  785.         preg_match_all ($pattern, $content, $matches);
  786.  
  787.         foreach ($matches[0] as $match)
  788.         {
  789.             $pattern = '[wp_eStore_fancy2:product_id:';
  790.             $m = str_replace ($pattern, '', $match);
  791.  
  792.             $pattern = ':end]';
  793.             $m = str_replace ($pattern, '', $m);
  794.  
  795.             $pieces = explode('|',$m);
  796.             $key = $pieces[0];
  797.  
  798.             if (sizeof($pieces) == 1)
  799.             {
  800.                 $replacement = show_product_fancy_style2($key);
  801.                 $content = str_replace ($match, $replacement, $content);
  802.             }
  803.         }
  804.         return $content;
  805. }
  806.  
  807. function eStore_print_products_from_category($content)
  808. {
  809.         $pattern = '#\[wp_eStore_category_products:category_id:.+:end]#';
  810.         preg_match_all ($pattern, $content, $matches);
  811.  
  812.         foreach ($matches[0] as $match)
  813.         {
  814.             $pattern = '[wp_eStore_category_products:category_id:';
  815.             $m = str_replace ($pattern, '', $match);
  816.  
  817.             $pattern = ':end]';
  818.             $m = str_replace ($pattern, '', $m);
  819.  
  820.             $pieces = explode('|',$m);
  821.             $key = $pieces[0];
  822.  
  823.             if (sizeof($pieces) == 1)
  824.             {
  825.                 $replacement = show_products_from_category($key);
  826.                 $content = str_replace ($match, $replacement, $content);
  827.             }
  828.         }
  829.         return $content;
  830. }
  831. //*********** Start of deprecated method ************
  832. function filter_wp_eStore_buy_now_button($content)
  833. {
  834.         $addcart_eStore = get_option('addToCartButtonName');
  835.         if (!$addcart_eStore || ($addcart_eStore == '') )
  836.             $addcart_eStore = 'Add to Cart';
  837.  
  838.         $pattern = '#\[wp_eStore_buy_now:product_id:.+button_text:.+:end]#';
  839.         preg_match_all ($pattern, $content, $matches);
  840.  
  841.         global $wpdb;
  842.         $products_table_name = $wpdb->prefix . "wp_eStore_tbl";
  843.  
  844.         foreach ($matches[0] as $match)
  845.         {
  846.             $pattern = '[wp_eStore_buy_now:product_id:';
  847.             $m = str_replace ($pattern, '', $match);
  848.  
  849.             $pattern = 'button_text:';
  850.             $m = str_replace ($pattern, '', $m);
  851.  
  852.             $pattern = ':end]';
  853.             $m = str_replace ($pattern, '', $m);
  854.  
  855.             $pieces = explode('|',$m);
  856.             if (sizeof($pieces) == 2)
  857.             {
  858.                 $key = $pieces[0];
  859.                 $button_text = $pieces[1];
  860.                 $replacement = print_wp_eStore_buy_now_button($key, $button_text);
  861.                 $content = str_replace ($match, $replacement, $content);
  862.             }
  863.         }
  864.         return $content;
  865. }
  866. //************* end of deprecated method ************
  867.  
  868. function filter_eStore_buy_now_button($content)
  869. {
  870.         $pattern = '#\[wp_eStore_buy_now:product_id:.+:end]#';
  871.         preg_match_all ($pattern, $content, $matches);
  872.  
  873.         foreach ($matches[0] as $match)
  874.         {
  875.             $pattern = '[wp_eStore_buy_now:product_id:';
  876.             $m = str_replace ($pattern, '', $match);
  877.  
  878.             $pattern = ':end]';
  879.             $m = str_replace ($pattern, '', $m);
  880.  
  881.             $pieces = explode('|',$m);
  882.             $key = $pieces[0];
  883.  
  884.             if (sizeof($pieces) == 1)
  885.             {
  886.                 $replacement = print_eStore_buy_now_button($key);
  887.                 $content = str_replace ($match, $replacement, $content);
  888.             }
  889.         }
  890.         return $content;
  891. }
  892.  
  893. function filter_eStore_subscribe_button($content)
  894. {
  895.         $pattern = '#\[wp_eStore_subscribe:product_id:.+:end]#';
  896.         preg_match_all ($pattern, $content, $matches);
  897.  
  898.         foreach ($matches[0] as $match)
  899.         {
  900.             $pattern = '[wp_eStore_subscribe:product_id:';
  901.             $m = str_replace ($pattern, '', $match);
  902.  
  903.             $pattern = ':end]';
  904.             $m = str_replace ($pattern, '', $m);
  905.  
  906.             $pieces = explode('|',$m);
  907.             $key = $pieces[0];
  908.  
  909.             if (sizeof($pieces) == 1)
  910.             {
  911.                 $replacement = print_eStore_subscribe_button_form($key);
  912.                 $content = str_replace ($match, $replacement, $content);
  913.             }
  914.         }
  915.         return $content;
  916. }
  917.  
  918. function filter_eStore_free_download_form($content)
  919. {
  920.         $pattern = '#\[wp_eStore_free_download:product_id:.+:end]#';
  921.         preg_match_all ($pattern, $content, $matches);
  922.  
  923.         foreach ($matches[0] as $match)
  924.         {
  925.             $pattern = '[wp_eStore_free_download:product_id:';
  926.             $m = str_replace ($pattern, '', $match);
  927.  
  928.             $pattern = ':end]';
  929.             $m = str_replace ($pattern, '', $m);
  930.  
  931.             $pieces = explode('|',$m);
  932.             $key = $pieces[0];
  933.  
  934.             if (sizeof($pieces) == 1)
  935.             {
  936.                 $replacement = eStore_free_download_form($key);
  937.                 $content = str_replace ($match, $replacement, $content);
  938.             }
  939.         }
  940.         return $content;
  941. }
  942.  
  943. function filter_eStore_free_download_form_ajax($content)
  944. {
  945.         $pattern = '#\[wp_eStore_free_download_ajax:product_id:.+:end]#';
  946.         preg_match_all ($pattern, $content, $matches);
  947.  
  948.         foreach ($matches[0] as $match)
  949.         {
  950.             $pattern = '[wp_eStore_free_download_ajax:product_id:';
  951.             $m = str_replace ($pattern, '', $match);
  952.  
  953.             $pattern = ':end]';
  954.             $m = str_replace ($pattern, '', $m);
  955.  
  956.             $pieces = explode('|',$m);
  957.             $key = $pieces[0];
  958.  
  959.             if (sizeof($pieces) == 1)
  960.             {
  961.                 $replacement = eStore_free_download_form_ajax($key);
  962.                 $content = str_replace ($match, $replacement, $content);
  963.             }
  964.         }
  965.         return $content;
  966. }
  967.  
  968. function digi_cart_not_empty()
  969. {
  970.         $count = 0;
  971.         if (isset($_SESSION['eStore_cart']) && is_array($_SESSION['eStore_cart']))
  972.         {
  973.             foreach ($_SESSION['eStore_cart'] as $item)
  974.                 $count++;
  975.             return $count;
  976.         }
  977.         else
  978.             return 0;
  979. }
  980.  
  981. function print_digi_cart_payment_currency($price, $symbol, $decimal)
  982. {
  983.     return $symbol.number_format($price, 2, $decimal, ',');
  984. }
  985.  
  986. function digi_cart_current_page_url()
  987. {
  988.     $pageURL = 'http';
  989.     if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
  990.     $pageURL .= "://";
  991.     if ($_SERVER["SERVER_PORT"] != "80") {
  992.         $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
  993.     }
  994.     else
  995.     {
  996.         $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
  997.     }
  998.     return $pageURL;
  999. }
  1000. function get_eStore_smart_thumb($img_url)
  1001. {
  1002.     $src = WP_ESTORE_LIB_URL.'/timthumb.php?src='.$img_url.'&h=125&w=125&zc=1&q=100';
  1003.     return $src;
  1004. }
  1005.  
  1006. function wp_eStore_clear_cache(){
  1007.     if ( function_exists('w3tc_pgcache_flush') ) {
  1008.       w3tc_pgcache_flush();
  1009.     } else if ( function_exists('wp_cache_clear_cache') ) {
  1010.       wp_cache_clear_cache();
  1011.     }
  1012. }
  1013.  
  1014. // Display The Options Page
  1015. function wp_digi_cart_admin_menu ()
  1016. {
  1017.      add_options_page('WP Sell Digital Products', 'WP Sell Digital Products', 'manage_options', __FILE__, 'wp_digi_cart_options');
  1018. }
  1019.  
  1020. function show_wp_digi_cart_widget($args)
  1021. {
  1022. if (!digi_cart_not_empty())
  1023. {
  1024. return;
  1025. }
  1026.     extract($args);
  1027.  
  1028.     $cart_title = get_option('wp_eStore_widget_title');
  1029.     if (empty($cart_title)) $cart_title = 'Shopping Cart';
  1030.  
  1031.     echo $before_widget;
  1032.     echo $before_title . $cart_title . $after_title;
  1033.     if (get_option('eStore_show_compact_cart'))
  1034.     {
  1035.         echo eStore_show_compact_cart();
  1036.     }
  1037.     else
  1038.     {
  1039.         echo print_wp_digi_cart();
  1040.     }
  1041.     echo $after_widget;
  1042. }
  1043.  
  1044. function wp_digi_cart_widget_control()
  1045. {
  1046.     ?>
  1047.     <p>
  1048.     <? _e("Set the Plugin Settings from the Settings menu"); ?>
  1049.     </p>
  1050.     <?php
  1051. }
  1052.  
  1053. function widget_wp_digi_cart_init()
  1054. {  
  1055.     $widget_options = array('classname' => 'widget_wp_digi_cart', 'description' => __( "Display WP Cart For Digital Products.") );
  1056.     wp_register_sidebar_widget('wp_digi_cart_widgets', __('WP Cart for Digital Products'), 'show_wp_digi_cart_widget', $widget_options);
  1057.     wp_register_widget_control('wp_digi_cart_widgets', __('WP Cart for Digital Products'), 'wp_digi_cart_widget_control' );
  1058. }
  1059.  
  1060.  
  1061. //if(get_option('eStore_enable_fancy_redirection_on_checkout')){
  1062. //add_action('wp_head', wp_eStore_load_current_jquery('1.4.2'));
  1063. //}
  1064. function wp_eStore_load_current_jquery($version) {
  1065.         global $wp_scripts;
  1066.         if ( ( version_compare($version, $wp_scripts -> registered[jquery] -> ver) == 1 ) && !is_admin() ) {
  1067.                 wp_deregister_script('jquery');  
  1068.                 wp_register_script('jquery',
  1069.                         'http://ajax.googleapis.com/ajax/libs/jquery/'.$version.'/jquery.min.js',
  1070.                         false, $version);
  1071.         }
  1072. }
  1073.  
  1074. function wp_eStore_load_libraries()
  1075. {
  1076.     wp_enqueue_script('jquery');
  1077.     if(!is_admin())
  1078.     {
  1079.         wp_enqueue_script('jquery.cookie',WP_ESTORE_LIB_URL.'/jquery.cookie.js');    
  1080.         wp_enqueue_script('jquery.lightbox',WP_ESTORE_LIB_URL.'/jquery.lightbox-0.5.min.js');  
  1081.        
  1082.         if(get_option('eStore_enable_fancy_redirection_on_checkout'))
  1083.         {
  1084.             wp_enqueue_script('jquery.tools',WP_ESTORE_LIB_URL.'/jquery.tools.min.js');
  1085.         }
  1086.     }      
  1087. }
  1088.  
  1089. function wp_eStore_head_content()
  1090. {  
  1091.     echo '<link type="text/css" rel="stylesheet" href="'.WP_ESTORE_URL.'/wp_eStore_style.css" />'."\n";
  1092.     echo '<link type="text/css" rel="stylesheet" href="'.WP_ESTORE_URL.'/wp_eStore_custom_style.css" />'."\n";
  1093.  
  1094.     echo '<script type="text/javascript" src="'.WP_ESTORE_URL.'/lib/eStore_read_form.js"></script>';
  1095. }
  1096.  
  1097. function wp_eStore_add_footer_code()
  1098. {
  1099.     if(get_option('eStore_enable_fancy_redirection_on_checkout'))
  1100.     {
  1101.         //Overlayed element
  1102.         $output .= '<div class="eStore_apple_overlay">';
  1103.         $output .= '<div class="cart_redirection_contentWrap"></div>';
  1104.         $output .= '</div>';   
  1105.         echo $output;                  
  1106.         eStore_load_fancy_overlay_jquery2();
  1107.     }  
  1108.     //echo '<script type="text/javascript" src="'.WP_ESTORE_URL.'/lib/jquery.cookie.js"></script>';
  1109.     if (get_option('eStore_enable_lightbox_effect') != '')
  1110.     {
  1111.         eStore_load_lightbox();
  1112.     }      
  1113. }
  1114.  
  1115. function eStore_tinyMCE_addbutton()
  1116. {
  1117.     // check user permission
  1118.     if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') )
  1119.     return;
  1120.     // Add only in Rich Editor mode
  1121.     if (get_user_option('rich_editing') == 'true')
  1122.     {
  1123.         add_filter("mce_external_plugins", "eStore_tinyMCE_load");
  1124.         add_filter('mce_buttons', 'eStore_tinyMCE_register_button');
  1125.     }
  1126. }
  1127. function eStore_tinyMCE_load($plugin_array)
  1128. {
  1129.     $plug = WP_ESTORE_LIB_URL . '/editor_plugin.js';
  1130.     $plugin_array['wpEstore'] = $plug;
  1131.     return $plugin_array;
  1132. }
  1133. function eStore_tinyMCE_register_button($buttons)
  1134. {
  1135.    array_push($buttons, "separator", "wpEstoreButton");
  1136.    return $buttons;
  1137. }
  1138.  
  1139. //Add the Admin Menus
  1140. define("ESTORE_MANAGEMENT_PERMISSION", "edit_themes");
  1141. if (is_admin())
  1142. {
  1143.     function wp_digi_cart_add_admin_menu()
  1144.     {
  1145.         add_menu_page(__("WP eStore", 'wp_eStore'), __("WP eStore", 'wp_eStore'), ESTORE_MANAGEMENT_PERMISSION, __FILE__, "wp_estore_product_management_menu");
  1146.         add_submenu_page(__FILE__, __("Manage WP eStore", 'wp_eStore'), __("Manage Products", 'wp_eStore'), ESTORE_MANAGEMENT_PERMISSION, __FILE__, "wp_estore_product_management_menu");
  1147.         add_submenu_page(__FILE__, __("Add/Edit WP eStore", 'wp_eStore'), __("Add/Edit Products", 'wp_eStore'), ESTORE_MANAGEMENT_PERMISSION, 'wp_eStore_addedit', "wp_estore_add_product_menu");
  1148.         add_submenu_page(__FILE__, __("WP eStore Categories", 'wp_eStore'), __("Categories", 'wp_eStore'), ESTORE_MANAGEMENT_PERMISSION, 'wp_eStore_categories', "wp_eStore_manage_categories_menu");
  1149.         add_submenu_page(__FILE__, __("WP eStore Stats", 'wp_eStore'), __("Stats", 'wp_eStore'), ESTORE_MANAGEMENT_PERMISSION, 'wp_eStore_stats', "wp_estore_stats_menu");
  1150.         add_submenu_page(__FILE__, __("WP eStore Settings", 'wp_eStore'), __("Settings", 'wp_eStore'), ESTORE_MANAGEMENT_PERMISSION, 'wp_eStore_settings', "wp_estore_settings_menu");
  1151.         add_submenu_page(__FILE__, __("WP eStore Admin", 'wp_eStore'), __("Admin Functions", 'wp_eStore'), ESTORE_MANAGEMENT_PERMISSION, 'wp_eStore_admin', "wp_estore_admin_menu");
  1152.         add_submenu_page(__FILE__, __("WP eStore Coupons", 'wp_eStore'), __("Coupons/Discounts", 'wp_eStore'), ESTORE_MANAGEMENT_PERMISSION, 'wp_eStore_discounts', "wp_estore_discounts_menu");
  1153.         add_submenu_page(__FILE__, __("eStore Manage Customers", 'wp_eStore'), __("Manage Customers", 'wp_eStore'), ESTORE_MANAGEMENT_PERMISSION, 'wp_estore_customer_management', "wp_estore_customer_management_menu");
  1154.         add_submenu_page(__FILE__, __("Add/Edit Customers", 'wp_eStore'), __("Add/Edit Customers", 'wp_eStore'), ESTORE_MANAGEMENT_PERMISSION, 'wp_eStore_customer_addedit', "wp_estore_add_customer_menu");
  1155.     }
  1156.     //Include menus
  1157.     require_once(dirname(__FILE__).'/wp_digi_cart_admin_menu.php');
  1158.     require_once(dirname(__FILE__).'/eStore_product_management.php');
  1159.     require_once(dirname(__FILE__).'/eStore_categories_menu.php');
  1160.     require_once(dirname(__FILE__).'/eStore_discounts_menu.php');
  1161.     require_once(dirname(__FILE__).'/eStore_stats_menu.php');
  1162.     require_once(dirname(__FILE__).'/eStore_customers_menu.php');
  1163. }
  1164.  
  1165. // Insert the options page to the admin menu
  1166. if (is_admin())
  1167. {
  1168.     add_action('admin_menu','wp_digi_cart_add_admin_menu');
  1169. }
  1170.  
  1171. add_action('init', 'wp_eStore_load_libraries');
  1172. add_action('init', 'eStore_tinyMCE_addbutton');
  1173. add_action('init', 'widget_wp_digi_cart_init');
  1174.  
  1175. add_filter('the_content', 'print_wp_digi_cart_button',11);
  1176. add_filter('the_content', 'eStore_fancy_product_display',11);
  1177. add_filter('the_content', 'eStore_fancy_product_display2');
  1178. add_filter('the_content', 'eStore_display_all_products_stylish',11);
  1179. add_filter('the_content', 'eStore_display_all_products_stylish2',11);
  1180. add_filter('the_content', 'eStore_print_products_from_category',11);
  1181. //add_filter('the_content', 'filter_wp_eStore_buy_now_button',11);
  1182. add_filter('the_content', 'filter_eStore_buy_now_button',11);
  1183. add_filter('the_content', 'filter_eStore_free_download_form',11);
  1184. add_filter('the_content', 'filter_eStore_free_download_form_ajax',11);
  1185. add_filter('the_content', 'filter_eStore_subscribe_button',11);
  1186. add_filter('the_content', 'wp_digi_cart_show');
  1187. add_filter('the_content', 'filter_wp_digi_cart_always_show');
  1188. add_filter('the_content', 'filter_eStore_transaction_result');
  1189. add_filter('the_content', 'wp_estore_products');
  1190.  
  1191. add_shortcode('wp_eStore_cart', 'wp_digi_cart_always_show');
  1192. add_shortcode('wp_eStore_cart_fancy1', 'eStore_shopping_cart_fancy1');
  1193. add_shortcode('wp_eStore_cart_fancy1_when_not_empty', 'eStore_shopping_cart_fancy1_when_not_empty');
  1194. add_shortcode('wp_eStore_cart_when_not_empty', 'eStore_cart_when_not_empty');
  1195. add_shortcode('wp_eStore_list_products', 'wp_estore_products_table');
  1196. add_shortcode('wp_eStore_list_categories_fancy', 'wp_estore_display_categories_fancy');
  1197. add_shortcode('wp_eStore_category_fancy', 'wp_estore_display_category_fancy');
  1198. add_shortcode('wp_eStore_fancy1', 'eStore_fancy1');
  1199. add_shortcode('wp_eStore_fancy2', 'eStore_fancy2');
  1200. add_shortcode('wp_eStore_buy_now_fancy', 'eStore_buy_now_fancy');
  1201. add_shortcode('wp_eStore_subscribe_fancy', 'eStore_subscribe_fancy');
  1202. add_shortcode('wp_eStore_sale_counter', 'eStore_sale_counter');
  1203. add_shortcode('wp_eStore_remaining_copies_counter', 'eStore_remaining_copies_counter');
  1204. add_shortcode('wp_eStore_download_now_button', 'eStore_download_now_button');
  1205. add_shortcode('wp_eStore_download_now_button_fancy', 'eStore_download_now_button_fancy');
  1206. add_shortcode('wp_eStore_download_now_button_fancy_no_price', 'eStore_download_now_button_fancy_no_price_handler');
  1207. add_shortcode('wp_eStore_buy_now_custom_button', 'wp_eStore_buy_now_custom_button_handler');
  1208. add_shortcode('wp_eStore_members_purchase_history', 'wp_eStore_members_purchase_history_handler');
  1209.  
  1210. add_filter('the_content', 'do_shortcode');
  1211. if (!is_admin())
  1212. {add_filter('widget_text', 'do_shortcode');}
  1213.  
  1214. add_action('wp_head', 'wp_eStore_head_content');
  1215. add_action('wp_footer', 'wp_eStore_add_footer_code');
  1216. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement