├── mypay_test.php ├── pay_test.php ├── vendor_profile.php ├── order_step01.php ├── shop_profile.php └── functions.php /mypay_test.php: -------------------------------------------------------------------------------- 1 | $product_id){ 14 | $quantity = 1; 15 | 16 | if ( WC()->cart->add_to_cart( $product_id, $quantity ) ) { 17 | do_action( 'woocommerce_ajax_added_to_cart', $product_id ); 18 | wc_add_to_cart_message( $product_id ); 19 | } 20 | } 21 | } 22 | 23 | $redirect_url = "http://mytemples.com/checkout"; 24 | wp_redirect( $redirect_url ); 25 | ?> -------------------------------------------------------------------------------- /pay_test.php: -------------------------------------------------------------------------------- 1 | $_POST["bill_name"], 10 | 'phone' => $_POST["mobile"], 11 | 'address_1' => $_POST["address"] 12 | ); 13 | 14 | $first_name = ""; 15 | $birthday = ""; 16 | $gender = ""; 17 | $address_1 = ""; 18 | 19 | if(count($_POST["prayerList_lights"]) == 0) exit(); 20 | 21 | for($i=0; $i $first_name, 36 | 'birthday' => $birthday, 37 | 'gender' => $gender, 38 | 'address_1' => $address_1 39 | ); 40 | 41 | $order = wc_create_order(); 42 | $order->add_product( get_product( $_POST["prayerList_lights"][0] ), count($_POST["prayerList_name"]) ); 43 | 44 | $order->set_address( $bill_address, 'billing' ); 45 | $order->set_address( $ship_address, 'shipping' ); 46 | $order->set_customer_id(get_current_user_id()); 47 | 48 | $order->calculate_totals(); 49 | 50 | // mssql insert start 51 | 52 | $user_id = $_POST['temple_id']; 53 | 54 | $userinfo = get_userdata($user_id); 55 | $user_metainfo = get_user_meta($user_id); 56 | 57 | $vendor_shop_name = $user_metainfo["pv_shop_name"][0]; 58 | $vendor_address = $user_metainfo["description"][0]; 59 | 60 | $vendor_seller_info = $user_metainfo["pv_seller_info"][0]; 61 | $vendor_description = $user_metainfo["pv_shop_description"][0]; 62 | 63 | $vendor_name = $user_metainfo["nickname"][0]; 64 | $vendor_email = $user_metainfo["billing_email"][0]; 65 | $vendor_phone = $user_metainfo["billing_phone"][0]; 66 | 67 | $product_id = $_POST["prayerList_lights"][0]; 68 | 69 | $per_page = 20; 70 | $args = array( 71 | 'post_type' => 'product', 72 | 'posts_per_page' => 3, 73 | 'orderby' => 'ID', 74 | 'order' => 'DESC', 75 | 'author' => $user_id, 76 | ); 77 | $product_obj = ""; 78 | $loop = new WP_Query($args); 79 | foreach($loop->posts as $product){ 80 | if($product_id == $product->ID){ 81 | $product_obj = $product; 82 | } 83 | } 84 | $product_name = ""; 85 | if($product_obj){ 86 | $product_name = $product_obj->post_title; 87 | } 88 | /* 89 | $myServer = "125.227.192.4"; 90 | $myUser = "sa"; 91 | $myPass = "wenhsuan01"; 92 | $myDB = "LightingDB"; 93 | 94 | ini_set('mssql.charset', 'UTF-8'); 95 | 96 | $dbhandle = mssql_connect($myServer, $myUser, $myPass) or die("Couldn't connect to SQL Server on $myServer"); 97 | 98 | $selected = mssql_select_db($myDB, $dbhandle) or die("Couldn't open database $myDB"); 99 | */ 100 | $payment_status = "0"; 101 | 102 | // $product = mb_convert_encoding($product, "BIG5"); 103 | 104 | for($i=0; $iid."',N'".$first_name."','".$_POST["mobile"]."','".$vendor_address."','".$vendor_name ."','" . $product_name . "','" .$gender."','" . $birthday . "','" . date("Y-m-d H:i:s") . "','" . $address_1 . "','" . $payment_status . "','" . $vendor_shop_name . "') "; 111 | 112 | // echo $insert_val; 113 | // $res = mssql_query($insert_val); 114 | 115 | } 116 | 117 | 118 | // mssql insert end 119 | 120 | update_post_meta( $order->id, '_payment_method', 'Credit' ); 121 | update_post_meta( $order->id, '_payment_method_title', 'Credit' ); 122 | 123 | WC()->session->order_awaiting_payment = $order->id; 124 | $available_gateways = WC()->payment_gateways->get_available_payment_gateways(); 125 | $result = $available_gateways[ 'ecpay' ]->process_payment( $order->id ); 126 | 127 | $successCheck = ( $result['result'] == 'success' ); 128 | $redirect_url = $result["redirect"]; 129 | $redirect_url .= "&pay_for_order=true"; 130 | 131 | if ( $successCheck ) { 132 | wp_redirect( $redirect_url ); 133 | exit; 134 | } 135 | ?> -------------------------------------------------------------------------------- /vendor_profile.php: -------------------------------------------------------------------------------- 1 | 'product', 25 | 'posts_per_page' => 3, 26 | 'orderby' => 'ID', 27 | 'order' => 'DESC', 28 | 'author' => $user_id, 29 | ); 30 | $loop = new WP_Query($args); 31 | 32 | ?> 33 | 239 | 240 | 277 |
278 |
279 |
280 |
281 |

282 |
283 |
    284 |
  • 285 |
  • 286 | 287 |

    主祀神祇 :

    288 |

    電子郵件 :

    289 |

    電話號碼 :

    290 |
    291 | posts as $product){ 294 | ?> 295 | post_title?> 296 | 297 |
    298 |
  • 299 |
300 |
301 |

302 |
303 |
304 | 326 |
-------------------------------------------------------------------------------- /order_step01.php: -------------------------------------------------------------------------------- 1 | 'product', 28 | 'posts_per_page' => 3, 29 | 'orderby' => 'ID', 30 | 'order' => 'DESC', 31 | 'author' => $user_id, 32 | ); 33 | $product_obj = ""; 34 | $loop = new WP_Query($args); 35 | foreach($loop->posts as $product){ 36 | if($product_id == $product->ID){ 37 | $product_obj = $product; 38 | } 39 | } 40 | $product_price = ""; 41 | if($product_obj){ 42 | $product_price = get_post_meta($product_id,'_price',true); 43 | } 44 | ?> 45 | 46 | 255 | 256 | 257 | 258 | 259 | 260 | 311 |
312 |
313 | 314 |
315 |
316 | 325 |
326 |
327 |
328 |

聯絡人資料(付款人) 329 |
*為必填資料
330 |

331 |
332 | 333 | 334 | 335 | 338 | 339 | 340 | 341 | 344 | 345 | 346 | 347 | 350 | 351 |
*姓名: 336 | 337 |
*手機號碼: 342 | 343 |
*地址: 348 | 349 |
352 |
353 |
354 |
355 |
356 |
357 | 增加祈福者 358 | 訂單提交 359 |
360 |
361 |
362 | -------------------------------------------------------------------------------- /shop_profile.php: -------------------------------------------------------------------------------- 1 | 'product', 25 | 'posts_per_page' => 3, 26 | 'orderby' => 'ID', 27 | 'order' => 'DESC', 28 | 'author' => $user_id, 29 | ); 30 | $loop = new WP_Query($args); 31 | 32 | ?> 33 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 550 |
551 |
552 |
553 |
554 |

555 |
556 |
    557 |
  • 558 |
  • 559 | 560 |

    主祀神祇 :

    561 |

    電子郵件 :

    562 |

    電話號碼 :

    563 |
    564 | posts as $product){ 567 | ?> 568 | post_title?> 569 | 570 |
    571 |
  • 572 |
573 |
574 |

575 |
576 |
577 | 578 |
579 | 601 | 602 |
603 | 604 |
605 |
606 | 增加祈福者 607 | 訂單提交 608 |
609 |
610 | 613 |
614 | 615 | 616 | -------------------------------------------------------------------------------- /functions.php: -------------------------------------------------------------------------------- 1 | disableUpdater(true); 94 | 95 | 96 | //enable vc on post types 97 | if(function_exists('vc_set_default_editor_post_types')) vc_set_default_editor_post_types( array('post','page','product','portfolio') ); 98 | 99 | // Modify and remove existing shortcodes from VC 100 | include_once('inc/shortcodes/visual-composer/custom_vc.php'); 101 | 102 | // VC Templates 103 | $vc_templates_dir = get_template_directory() . '/inc/shortcodes/visual-composer/vc_templates/'; 104 | vc_set_shortcodes_templates_dir($vc_templates_dir); 105 | 106 | // Add new shortcodes to VC 107 | include_once('inc/shortcodes/visual-composer/from-the-blog.php'); 108 | include_once('inc/shortcodes/visual-composer/social-media-profiles.php'); 109 | include_once('inc/shortcodes/visual-composer/google-map.php'); 110 | include_once(locate_template('inc/shortcodes/visual-composer/banner.php')); 111 | include_once('inc/shortcodes/visual-composer/icon-box.php'); 112 | include_once('inc/shortcodes/visual-composer/portfolio.php'); 113 | include_once(locate_template('inc/shortcodes/visual-composer/slider.php')); 114 | 115 | // Add new Shop shortcodes to VC 116 | if (class_exists('WooCommerce')) { 117 | // include_once('inc/shortcodes/visual-composer/wc-recent-products.php'); 118 | // include_once('inc/shortcodes/visual-composer/wc-featured-products.php'); 119 | // include_once('inc/shortcodes/visual-composer/wc-products-by-category.php'); 120 | // include_once('inc/shortcodes/visual-composer/wc-products-by-attribute.php'); 121 | // include_once('inc/shortcodes/visual-composer/wc-product-by-id-sku.php'); 122 | // include_once('inc/shortcodes/visual-composer/wc-products-by-ids-skus.php'); 123 | // include_once('inc/shortcodes/visual-composer/wc-sale-products.php'); 124 | // include_once('inc/shortcodes/visual-composer/wc-top-rated-products.php'); 125 | // include_once('inc/shortcodes/visual-composer/wc-best-selling-products.php'); 126 | // include_once('inc/shortcodes/visual-composer/wc-add-to-cart-button.php'); 127 | // include_once('inc/shortcodes/visual-composer/wc-product-categories.php'); 128 | include_once('inc/shortcodes/visual-composer/wc-product-categories-grid.php'); 129 | } 130 | 131 | // Remove vc_teaser 132 | if (is_admin()) : 133 | function remove_vc_teaser() { 134 | remove_meta_box('vc_teaser', '' , 'side'); 135 | } 136 | add_action( 'admin_head', 'remove_vc_teaser' ); 137 | endif; 138 | 139 | } 140 | 141 | } 142 | 143 | add_action( 'vc_before_init', 'shopkeeper_vcSetAsTheme' ); 144 | function shopkeeper_vcSetAsTheme() { 145 | vc_manager()->disableUpdater(true); 146 | vc_set_as_theme(); 147 | } 148 | 149 | 150 | /******************************************************************************/ 151 | /****************************** Ajax url **************************************/ 152 | /******************************************************************************/ 153 | 154 | add_action('wp_head','shopkeeper_ajaxurl'); 155 | function shopkeeper_ajaxurl() { 156 | ?> 157 | 160 | 170 | 173 | __( 'Top Bar Navigation', 'shopkeeper' ), 225 | 'main-navigation' => __( 'Main Navigation', 'shopkeeper' ), 226 | 'footer-navigation' => __( 'Footer Navigation', 'shopkeeper' ), 227 | ) ); 228 | 229 | if ( (isset($shopkeeper_theme_options['main_header_off_canvas'])) && (trim($shopkeeper_theme_options['main_header_off_canvas']) == "1" ) ) { 230 | register_nav_menus( array( 231 | 'secondary_navigation' => __( 'Secondary Navigation (Off-Canvas)', 'shopkeeper' ), 232 | ) ); 233 | } 234 | 235 | if ( (isset($shopkeeper_theme_options['main_header_layout'])) && ( $shopkeeper_theme_options['main_header_layout'] == "2" || $shopkeeper_theme_options['main_header_layout'] == "22" ) ) { 236 | register_nav_menus( array( 237 | 'centered_header_left_navigation' => __( 'Centered Header - Left Navigation', 'shopkeeper' ), 238 | 'centered_header_right_navigation' => __( 'Centered Header - Right Navigation', 'shopkeeper' ), 239 | ) ); 240 | } 241 | 242 | /** WooCommerce Number of products displayed per page **/ 243 | if ( (isset($shopkeeper_theme_options['products_per_page'])) ) { 244 | add_filter( 'loop_shop_per_page', create_function( '$cols', 'return ' . $shopkeeper_theme_options['products_per_page'] . ';' ), 20 ); 245 | } 246 | 247 | /******************************************************************************/ 248 | /* WooCommerce remove review tab **********************************************/ 249 | /******************************************************************************/ 250 | if ( (isset($shopkeeper_theme_options['review_tab'])) && ($shopkeeper_theme_options['review_tab'] == "0" ) ) { 251 | add_filter( 'woocommerce_product_tabs', 'shopkeeper_remove_reviews_tab', 98); 252 | function shopkeeper_remove_reviews_tab($tabs) { 253 | unset($tabs['reviews']); 254 | return $tabs; 255 | } 256 | } 257 | } 258 | endif; // shopkeeper_setup 259 | add_action( 'after_setup_theme', 'shopkeeper_setup' ); 260 | 261 | /******************************************************************************/ 262 | /**************************** Enqueue styles **********************************/ 263 | /******************************************************************************/ 264 | 265 | // frontend 266 | function shopkeeper_styles() { 267 | 268 | global $shopkeeper_theme_options; 269 | 270 | if ( (isset($shopkeeper_theme_options['smooth_transition_between_pages'])) && ($shopkeeper_theme_options['smooth_transition_between_pages'] == "1" ) ) { 271 | wp_enqueue_style('shopkeeper-page-in-out', get_template_directory_uri() . '/css/page-in-out.css', NULL, getbowtied_theme_version(), 'all' ); 272 | } 273 | wp_enqueue_style('shopkeeper-styles', get_template_directory_uri() . '/css/styles.css', NULL, getbowtied_theme_version(), 'all' ); 274 | 275 | wp_enqueue_style('shopkeeper-icon-font', get_template_directory_uri() . '/inc/fonts/shopkeeper-icon-font/style.css', NULL, getbowtied_theme_version(), 'all' ); 276 | 277 | wp_enqueue_style('shopkeeper-font-awesome', get_template_directory_uri() . '/inc/fonts/font-awesome/css/font-awesome.min.css', NULL, '4.6.3', 'all' ); 278 | wp_enqueue_style('shopkeeper-font-linea-arrows', get_template_directory_uri() . '/inc/fonts/linea-fonts/arrows/styles.css', NULL, getbowtied_theme_version(), 'all' ); 279 | wp_enqueue_style('shopkeeper-font-linea-basic', get_template_directory_uri() . '/inc/fonts/linea-fonts/basic/styles.css', NULL, getbowtied_theme_version(), 'all' ); 280 | wp_enqueue_style('shopkeeper-font-linea-basic_elaboration', get_template_directory_uri() . '/inc/fonts/linea-fonts/basic_elaboration/styles.css', NULL, getbowtied_theme_version(), 'all' ); 281 | wp_enqueue_style('shopkeeper-font-linea-ecommerce', get_template_directory_uri() . '/inc/fonts/linea-fonts/ecommerce/styles.css', NULL, getbowtied_theme_version(), 'all' ); 282 | wp_enqueue_style('shopkeeper-font-linea-music', get_template_directory_uri() . '/inc/fonts/linea-fonts/music/styles.css', NULL, getbowtied_theme_version(), 'all' ); 283 | wp_enqueue_style('shopkeeper-font-linea-software', get_template_directory_uri() . '/inc/fonts/linea-fonts/software/styles.css', NULL, getbowtied_theme_version(), 'all' ); 284 | wp_enqueue_style('shopkeeper-font-linea-weather', get_template_directory_uri() . '/inc/fonts/linea-fonts/weather/styles.css', NULL, getbowtied_theme_version(), 'all' ); 285 | 286 | wp_enqueue_style('shopkeeper-fresco', get_template_directory_uri() . '/css/fresco/fresco.css', NULL, '1.3.0', 'all' ); 287 | 288 | if ( isset($shopkeeper_theme_options['main_header_layout']) ) { 289 | if ( $shopkeeper_theme_options['main_header_layout'] == "1" || $shopkeeper_theme_options['main_header_layout'] == "11" ) { 290 | wp_enqueue_style('shopkeeper-header-default', get_template_directory_uri() . '/css/header-default.css', NULL, getbowtied_theme_version(), 'all' ); 291 | } 292 | elseif ( $shopkeeper_theme_options['main_header_layout'] == "2" || $shopkeeper_theme_options['main_header_layout'] == "22" ) { 293 | wp_enqueue_style('shopkeeper-header-centered-2menus', get_template_directory_uri() . '/css/header-centered-2menus.css', NULL, getbowtied_theme_version(), 'all' ); 294 | } 295 | elseif ( $shopkeeper_theme_options['main_header_layout'] == "3" ) { 296 | wp_enqueue_style('shopkeeper-header-centered-menu-under', get_template_directory_uri() . '/css/header-centered-menu-under.css', NULL, getbowtied_theme_version(), 'all' ); 297 | } 298 | } 299 | else { 300 | wp_enqueue_style('shopkeeper-header-default', get_template_directory_uri() . '/css/header-default.css', NULL, getbowtied_theme_version(), 'all' ); 301 | } 302 | 303 | wp_enqueue_style('shopkeeper-default-style', get_stylesheet_uri()); 304 | 305 | } 306 | add_action( 'wp_enqueue_scripts', 'shopkeeper_styles', 99 ); 307 | 308 | 309 | 310 | // admin area 311 | function shopkeeper_admin_styles() { 312 | if ( is_admin() ) { 313 | 314 | wp_enqueue_style("wp-color-picker"); 315 | wp_enqueue_style("shopkeeper_admin_styles", get_template_directory_uri() . "/css/wp-admin-custom.css", false, getbowtied_theme_version(), "all"); 316 | 317 | if (class_exists('WPBakeryVisualComposerAbstract')) { 318 | wp_enqueue_style('shopkeeper_visual_composer', get_template_directory_uri() .'/css/visual-composer.css', false, getbowtied_theme_version(), 'all'); 319 | wp_enqueue_style('shopkeeper-font-linea-arrows', get_template_directory_uri() . '/inc/fonts/linea-fonts/arrows/styles.css', false, getbowtied_theme_version(), 'all' ); 320 | wp_enqueue_style('shopkeeper-font-linea-basic', get_template_directory_uri() . '/inc/fonts/linea-fonts/basic/styles.css', false, getbowtied_theme_version(), 'all' ); 321 | wp_enqueue_style('shopkeeper-font-linea-basic_elaboration', get_template_directory_uri() . '/inc/fonts/linea-fonts/basic_elaboration/styles.css', false, getbowtied_theme_version(), 'all' ); 322 | wp_enqueue_style('shopkeeper-font-linea-ecommerce', get_template_directory_uri() . '/inc/fonts/linea-fonts/ecommerce/styles.css', false, getbowtied_theme_version(), 'all' ); 323 | wp_enqueue_style('shopkeeper-font-linea-music', get_template_directory_uri() . '/inc/fonts/linea-fonts/music/styles.css', false, getbowtied_theme_version(), 'all' ); 324 | wp_enqueue_style('shopkeeper-font-linea-software', get_template_directory_uri() . '/inc/fonts/linea-fonts/software/styles.css', false, getbowtied_theme_version(), 'all' ); 325 | wp_enqueue_style('shopkeeper-font-linea-weather', get_template_directory_uri() . '/inc/fonts/linea-fonts/weather/styles.css', false, getbowtied_theme_version(), 'all' ); 326 | } 327 | } 328 | } 329 | add_action( 'admin_enqueue_scripts', 'shopkeeper_admin_styles' ); 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | /******************************************************************************/ 338 | /*************************** Enqueue scripts **********************************/ 339 | /******************************************************************************/ 340 | 341 | // frontend 342 | 343 | function shopkeeper_scripts_header_priority_0() { 344 | 345 | global $shopkeeper_theme_options; 346 | 347 | if ( (isset($shopkeeper_theme_options['smooth_transition_between_pages'])) && ($shopkeeper_theme_options['smooth_transition_between_pages'] == "1" ) ) { 348 | wp_enqueue_script('shopkeeper-nprogress', get_template_directory_uri() . '/js/components/nprogress.js', NULL, getbowtied_theme_version(), FALSE); 349 | wp_enqueue_script('shopkeeper-page-in-out', get_template_directory_uri() . '/js/components/page-in-out.js', array('shopkeeper-nprogress', 'jquery'), getbowtied_theme_version(), FALSE); 350 | } 351 | 352 | } 353 | add_action( 'wp_enqueue_scripts', 'shopkeeper_scripts_header_priority_0', 0 ); 354 | 355 | function shopkeeper_scripts() { 356 | 357 | global $shopkeeper_theme_options; 358 | 359 | /** In Footer **/ 360 | if( is_rtl() ) 361 | { 362 | wp_enqueue_script('shopkeeper-rtl-js', get_template_directory_uri() . '/js/components/rtl.js', array('jquery'), getbowtied_theme_version(), TRUE); 363 | } 364 | 365 | // wp_enqueue_script('shopkeeper-scripts-dist', get_template_directory_uri() . '/js/scripts-dist.js', array('jquery'), getbowtied_theme_version(), TRUE); 366 | 367 | if ( GETBOWTIED_VISUAL_COMPOSER_IS_ACTIVE) // If VC exists/active load scripts after VC 368 | { 369 | $dependencies = array('jquery', 'wpb_composer_front_js'); 370 | } 371 | else // Do not depend on VC 372 | { 373 | $dependencies = array('jquery'); 374 | } 375 | 376 | wp_enqueue_script('shopkeeper-scripts-dist', get_template_directory_uri() . '/js/scripts-dist.js', $dependencies, getbowtied_theme_version(), TRUE); 377 | 378 | if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { 379 | wp_enqueue_script( 'comment-reply' ); 380 | } 381 | 382 | 383 | $getbowtied_scripts_vars_array = array( 384 | 385 | 'ajax_load_more_locale' => __( 'Load More Items', 'shopkeeper' ), 386 | 'ajax_loading_locale' => __( 'Loading', 'shopkeeper' ), 387 | 'ajax_no_more_items_locale' => __( 'No more items available.', 'shopkeeper' ), 388 | 389 | 'pagination_blog' => isset($shopkeeper_theme_options['pagination_blog'])? $shopkeeper_theme_options['pagination_blog'] : 'infinite_scroll', 390 | 'layout_blog' => isset($shopkeeper_theme_options['layout_blog'])? $shopkeeper_theme_options['layout_blog'] : 'layout-1', 391 | 'shop_pagination_type' => isset($shopkeeper_theme_options['pagination_shop'])? $shopkeeper_theme_options['pagination_shop'] : 'infinite_scroll', 392 | 393 | 'option_minicart' => isset($shopkeeper_theme_options['option_minicart'])? $shopkeeper_theme_options['option_minicart'] : '1', 394 | 'catalog_mode' => (isset($shopkeeper_theme_options['catalog_mode']) && $shopkeeper_theme_options['catalog_mode'] == 1) ? '1' : '0', 395 | 'product_lightbox' => (isset($shopkeeper_theme_options['product_gallery_lightbox']) && $shopkeeper_theme_options['product_gallery_lightbox'] == 1) ? '1' : '0' 396 | 397 | ); 398 | 399 | wp_localize_script( 'shopkeeper-scripts-dist', 'getbowtied_scripts_vars', $getbowtied_scripts_vars_array ); 400 | 401 | } 402 | add_action( 'wp_enqueue_scripts', 'shopkeeper_scripts', 99 ); 403 | 404 | 405 | 406 | // admin area 407 | function shopkeeper_admin_scripts() { 408 | if ( is_admin() ) { 409 | global $post_type; 410 | 411 | if ( (isset($_GET['post_type']) && ($_GET['post_type'] == 'portfolio')) || ($post_type == 'portfolio')) : 412 | wp_enqueue_script("shopkeeper_admin_scripts", get_template_directory_uri() . "/js/components/wp-admin-portfolio.js", array('wp-color-picker'), false, getbowtied_theme_version()); 413 | endif; 414 | 415 | } 416 | } 417 | add_action( 'admin_enqueue_scripts', 'shopkeeper_admin_scripts' ); 418 | 419 | 420 | 421 | 422 | 423 | /*********************************************************************************************/ 424 | /******************************** Tweak WP admin bar ****************************************/ 425 | /*********************************************************************************************/ 426 | 427 | add_action( 'wp_head', 'shopkeeper_override_toolbar_margin', 11 ); 428 | function shopkeeper_override_toolbar_margin() { 429 | if ( is_admin_bar_showing() ) { 430 | ?> 431 | 437 | __( 'Sidebar', 'shopkeeper' ), 475 | 'id' => 'default-sidebar', 476 | 'before_widget' => '', 478 | 'before_title' => '

', 479 | 'after_title' => '

', 480 | )); 481 | 482 | //footer widget area 483 | register_sidebar( array( 484 | 'name' => __( 'Footer Widget Area', 'shopkeeper' ), 485 | 'id' => 'footer-widget-area', 486 | 'before_widget' => '
', 488 | 'before_title' => '

', 489 | 'after_title' => '

', 490 | ) ); 491 | 492 | //catalog widget area 493 | register_sidebar( array( 494 | 'name' => __( 'Shop Sidebar', 'shopkeeper' ), 495 | 'id' => 'catalog-widget-area', 496 | 'before_widget' => '', 498 | 'before_title' => '

', 499 | 'after_title' => '

', 500 | ) ); 501 | 502 | //offcanvas widget area 503 | register_sidebar( array( 504 | 'name' => __( 'Right Offcanvas Sidebar', 'shopkeeper' ), 505 | 'id' => 'offcanvas-widget-area', 506 | 'before_widget' => '', 508 | 'before_title' => '

', 509 | 'after_title' => '

', 510 | ) ); 511 | } 512 | add_action( 'widgets_init', 'shopkeeper_widgets_init' ); 513 | 514 | 515 | 516 | 517 | 518 | /******************************************************************************/ 519 | /****** Remove Woocommerce prettyPhoto ***********************************************/ 520 | /******************************************************************************/ 521 | 522 | add_action( 'wp_enqueue_scripts', 'shopkeeper_remove_woo_lightbox', 99 ); 523 | function shopkeeper_remove_woo_lightbox() { 524 | wp_dequeue_script('prettyPhoto-init'); 525 | } 526 | 527 | 528 | 529 | /*********************************************************************************************/ 530 | /****************************** WooCommerce Category Image ***********************************/ 531 | /*********************************************************************************************/ 532 | 533 | if ( ! function_exists( 'woocommerce_add_category_header_img' ) ) : 534 | require_once('inc/addons/woocommerce-header-category-image.php'); 535 | endif; 536 | 537 | 538 | 539 | /******************************************************************************/ 540 | /****** Add Fresco to Galleries ***********************************************/ 541 | /******************************************************************************/ 542 | 543 | add_filter( 'wp_get_attachment_link', 'sant_prettyadd', 10, 6); 544 | function sant_prettyadd ($content, $id, $size, $permalink, $icon, $text) { 545 | if ($permalink) { 546 | return $content; 547 | } 548 | $content = preg_replace("/' 561 | $defaults['delimiter'] = ' / '; 562 | return $defaults; 563 | } 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | /******************************************************************************/ 572 | /****** Add Font Awesome to Redux *********************************************/ 573 | /******************************************************************************/ 574 | 575 | function newIconFont() { 576 | 577 | wp_register_style( 578 | 'redux-font-awesome', 579 | get_template_directory_uri() . '/inc/fonts/font-awesome/css/font-awesome.min.css', 580 | array(), 581 | time(), 582 | 'all' 583 | ); 584 | wp_enqueue_style( 'redux-font-awesome' ); 585 | } 586 | add_action( 'redux/page/shopkeeper_theme_options/enqueue', 'newIconFont' ); 587 | 588 | 589 | 590 | 591 | /******************************************************************************/ 592 | /* Remove Admin Bar - Only display to administrators **************************/ 593 | /******************************************************************************/ 594 | 595 | add_action('after_setup_theme', 'remove_admin_bar'); 596 | function remove_admin_bar() { 597 | if (!current_user_can('administrator') && !is_admin()) { 598 | show_admin_bar(false); 599 | } 600 | } 601 | 602 | 603 | 604 | 605 | /******************************************************************************/ 606 | /* WooCommerce Update Number of Items in the cart *****************************/ 607 | /******************************************************************************/ 608 | 609 | add_action('woocommerce_ajax_added_to_cart', 'shopkeeper_ajax_added_to_cart'); 610 | function shopkeeper_ajax_added_to_cart() { 611 | 612 | } 613 | 614 | 615 | //================================================================================ 616 | // Update local storage with cart counter each time 617 | //================================================================================ 618 | 619 | add_filter('woocommerce_add_to_cart_fragments', 'shopkeeper_shopping_bag_items_number'); 620 | function shopkeeper_shopping_bag_items_number( $fragments ) 621 | { 622 | global $woocommerce; 623 | ob_start(); ?> 624 | 625 | cart->get_cart_contents_count()); ?> 626 | '4', 642 | 'orderby' => 'rand' 643 | ); 644 | woocommerce_related_products($atts); 645 | } 646 | 647 | 648 | 649 | 650 | 651 | 652 | /******************************************************************************/ 653 | /* WooCommerce Add data-src & lazyOwl to Thumbnails ***************************/ 654 | /******************************************************************************/ 655 | function woocommerce_get_product_thumbnail( $size = 'product_small_thumbnail', $placeholder_width = 0, $placeholder_height = 0 ) { 656 | global $post; 657 | 658 | if ( has_post_thumbnail() ) { 659 | $image_src = wp_get_attachment_image_src( get_post_thumbnail_id(), 'shop_catalog' ); 660 | return get_the_post_thumbnail( $post->ID, $size, array('data-src' => $image_src[0], 'class' => 'lazyOwl') ); 661 | //return '
'; 662 | } elseif ( wc_placeholder_img_src() ) { 663 | return wc_placeholder_img( $size ); 664 | } 665 | } 666 | 667 | 668 | 669 | 670 | 671 | 672 | /******************************************************************************/ 673 | /* WooCommerce Wrap Oembed Stuff **********************************************/ 674 | /******************************************************************************/ 675 | add_filter('embed_oembed_html', 'shopkeeper_embed_oembed_html', 99, 4); 676 | function shopkeeper_embed_oembed_html($html, $url, $attr, $post_id) { 677 | return '
' . $html . '
'; 678 | } 679 | 680 | 681 | 682 | 683 | /******************************************************************************/ 684 | /* Share Product **************************************************************/ 685 | /******************************************************************************/ 686 | 687 | function getbowtied_single_share_product() { 688 | global $post, $product, $shopkeeper_theme_options; 689 | if ( (isset($shopkeeper_theme_options['sharing_options'])) && ($shopkeeper_theme_options['sharing_options'] == "1" ) ) : 690 | 691 | $src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), false, ''); //Get the Thumbnail URL 692 | 693 | ?> 694 | 695 |
696 | 697 |
698 | 699 | 700 | 701 |
702 | 703 |
704 | 705 | '350', // px 728 | 'height' => '435', // px 729 | 'crop' => 1 // true 730 | ); 731 | 732 | $single = array( 733 | 'width' => '570', // px 734 | 'height' => '708', // px 735 | 'crop' => 1 // true 736 | ); 737 | 738 | $thumbnail = array( 739 | 'width' => '70', // px 740 | 'height' => '87', // px 741 | 'crop' => 1 // false 742 | ); 743 | 744 | // Image sizes 745 | update_option( 'shop_catalog_image_size', $catalog ); // Product category thumbs 746 | update_option( 'shop_single_image_size', $single ); // Single product image 747 | update_option( 'shop_thumbnail_image_size', $thumbnail ); // Image gallery thumbs 748 | } 749 | 750 | if ( ! function_exists('shopkeeper_woocommerce_image_dimensions') ) : 751 | function shopkeeper_woocommerce_image_dimensions() { 752 | global $pagenow; 753 | 754 | if ( ! isset( $_GET['activated'] ) || $pagenow != 'themes.php' ) { 755 | return; 756 | } 757 | 758 | $catalog = array( 759 | 'width' => '350', // px 760 | 'height' => '435', // px 761 | 'crop' => 1 // true 762 | ); 763 | 764 | $single = array( 765 | 'width' => '570', // px 766 | 'height' => '708', // px 767 | 'crop' => 1 // true 768 | ); 769 | 770 | $thumbnail = array( 771 | 'width' => '70', // px 772 | 'height' => '87', // px 773 | 'crop' => 0 // false 774 | ); 775 | 776 | // Image sizes 777 | update_option( 'shop_catalog_image_size', $catalog ); // Product category thumbs 778 | update_option( 'shop_single_image_size', $single ); // Single product image 779 | update_option( 'shop_thumbnail_image_size', $thumbnail ); // Image gallery thumbs 780 | } 781 | add_action( 'after_switch_theme', 'shopkeeper_woocommerce_image_dimensions', 1 ); 782 | endif; 783 | 784 | if ( ! isset( $content_width ) ) $content_width = 900; 785 | 786 | /******************************************************************************/ 787 | /****** Limit number of cross-sells *******************************************/ 788 | /******************************************************************************/ 789 | add_filter('woocommerce_cross_sells_total', 'cartCrossSellTotal'); 790 | function cartCrossSellTotal($total) { 791 | $total = '2'; 792 | return $total; 793 | } 794 | 795 | //delete_option('getbowtied_tools_force_activate'); 796 | 797 | /******************************************************************************/ 798 | /****** Force GetbowtiedTools Update*******************************************/ 799 | /******************************************************************************/ 800 | if ( ! class_exists( 'GetbowtiedToolsUpdater') ) { 801 | require('inc/plugins/plugin-updater.php'); 802 | 803 | $plugin_update = new GetbowtiedToolsUpdater('1.0.1', 'https://my.getbowtied.com/getbowtied-tools/update.php', 'getbowtied-tools/index.php'); 804 | } 805 | 806 | /******************************************************************************/ 807 | /****** Custom Sale label *****************************************************/ 808 | /******************************************************************************/ 809 | 810 | add_filter('woocommerce_sale_flash', 'woocommerce_custom_sale_tag_sale_flash', 10, 3); 811 | function woocommerce_custom_sale_tag_sale_flash($original, $post, $product) { 812 | global $shopkeeper_theme_options; 813 | 814 | if (!empty($shopkeeper_theme_options['sale_label'])): 815 | echo ''.$shopkeeper_theme_options['sale_label'].''; 816 | else: 817 | echo ''; 818 | endif; 819 | } 820 | 821 | /******************************************************************************/ 822 | /****** whitelist style for wp_kses_post() *******************************/ 823 | /******************************************************************************/ 824 | 825 | add_action('init', 'my_html_tags_code', 10); 826 | function my_html_tags_code() { 827 | global $allowedposttags; 828 | $allowedposttags["style"] = array(); 829 | } 830 | 831 | /******************************************************************************/ 832 | /****** add image to added to cart notification *******************************/ 833 | /******************************************************************************/ 834 | 835 | add_filter('wc_add_to_cart_message_html', 'custom_add_to_cart_message', 10, 2); 836 | function custom_add_to_cart_message( $message, $product_id) { 837 | 838 | $img = wp_get_attachment_image_src( get_post_thumbnail_id(key($product_id)), 'shop_catalog' ); 839 | $img_url = $img[0]; 840 | 841 | $added_to_cart = '
847 |
'.$message.'
'; 848 | return $added_to_cart; 849 | } 850 | 851 | //============================================================================== 852 | // Wrap success notification text 853 | //============================================================================== 854 | add_filter('woocommerce_add_success', 'custom_add_success', 10, 1); 855 | function custom_add_success($message) { 856 | if (strpos($message, 'product_notification_background') === false): 857 | return '
'. $message .'
'; 858 | else: 859 | return $message; 860 | endif; 861 | } 862 | 863 | 864 | 865 | //============================================================================== 866 | // Wrap notice text 867 | //============================================================================== 868 | add_filter('woocommerce_add_notice', 'custom_add_notice', 10, 1); 869 | function custom_add_notice($message) { 870 | if (strpos($message, 'product_notification_background') === false): 871 | return '
'. $message .'
'; 872 | else: 873 | endif; 874 | } 875 | 876 | 877 | add_action('woocommerce_archive_description', 'custom_add_notice_search', 10, 1); 878 | 879 | function custom_add_notice_search($message) { 880 | 881 | if ( is_search() ) { 882 | return false; 883 | } 884 | } 885 | 886 | 887 | 888 | 889 | //============================================================================== 890 | // Show Woocommerce Cart Widget Everywhere 891 | //============================================================================== 892 | if ( ! function_exists('getbowtied_woocommerce_widget_cart_everywhere') ) : 893 | function getbowtied_woocommerce_widget_cart_everywhere() { 894 | return false; 895 | }; 896 | add_filter( 'woocommerce_widget_cart_is_hidden', 'getbowtied_woocommerce_widget_cart_everywhere', 10, 1 ); 897 | endif; 898 | 899 | 900 | //============================================================================== 901 | // Wishlist message notification remove 902 | //============================================================================== 903 | 904 | function yith_wcwl_added_to_cart_message( $message ){ 905 | return false; 906 | } 907 | add_action( 'yith_wcwl_added_to_cart_message', 'yith_wcwl_added_to_cart_message' ); 908 | 909 | 910 | 911 | 912 | //============================================================================== 913 | // Woocommerce Product Page Get Caption Text 914 | //============================================================================== 915 | function wp_get_attachment( $attachment_id ) { 916 | $attachment = get_post( $attachment_id ); 917 | return array( 918 | 'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ), 919 | 'caption' => $attachment->post_excerpt, 920 | 'description' => $attachment->post_content, 921 | 'href' => get_permalink( $attachment->ID ), 922 | 'src' => $attachment->guid, 923 | 'title' => $attachment->post_title 924 | ); 925 | } 926 | 927 | //============================================================================== 928 | // Continue shopping button on cart page 929 | //============================================================================== 930 | add_action( 'woocommerce_after_cart', 'shopkeeper_add_continue_shopping_button_to_cart' ); 931 | if ( ! function_exists('shopkeeper_add_continue_shopping_button_to_cart') ) : 932 | function shopkeeper_add_continue_shopping_button_to_cart() { 933 | $shop_page_url = get_permalink( wc_get_page_id( 'shop' ) ); 934 | if (!empty($shop_page_url)): 935 | echo '
'; 936 | echo ' '.__('Continue shopping', 'shopkeeper').''; 937 | echo '
'; 938 | endif; 939 | } 940 | endif; 941 | 942 | //============================================================================== 943 | // Custom WooCommerce related products 944 | //============================================================================== 945 | if ( ! function_exists( 'getbowtied_output_related' ) ) { 946 | function getbowtied_output_related() { 947 | global $shopkeeper_theme_options; 948 | if ( isset($shopkeeper_theme_options['related_products']) && ($shopkeeper_theme_options['related_products'] == 1) ) { 949 | echo '
'; 950 | echo '
'; 951 | $atts = array( 952 | 'columns' => '4', 953 | 'posts_per_page' => '4', 954 | 'orderby' => 'rand' 955 | ); 956 | woocommerce_related_products($atts); // Display 3 products in rows of 3 957 | echo '
'; 958 | echo '
'; 959 | } 960 | } 961 | } 962 | 963 | //============================================================================== 964 | // Custom WooCommerce upsells 965 | //============================================================================== 966 | if ( ! function_exists( 'getbowtied_output_upsells' ) ) { 967 | function getbowtied_output_upsells() { 968 | echo '
'; 969 | echo '
'; 970 | woocommerce_upsell_display( 4,4 ); // Display 3 products in rows of 3 971 | echo '
'; 972 | echo '
'; 973 | } 974 | } 975 | 976 | function process_mssql_task($order_id, $payment_status) { 977 | 978 | /* 979 | $myServer = "125.227.192.4"; 980 | $myUser = "sa"; 981 | $myPass = "wenhsuan01"; 982 | $myDB = "LightingDB"; 983 | 984 | ini_set('mssql.charset', 'UTF-8'); 985 | 986 | $dbhandle = mssql_connect($myServer, $myUser, $myPass) or die("Couldn't connect to SQL Server on $myServer"); 987 | 988 | $selected = mssql_select_db($myDB, $dbhandle) or die("Couldn't open database $myDB"); 989 | */ 990 | if($payment_status == 0){ 991 | session_start(); 992 | 993 | $__TPOST = $_SESSION["orderInfo"]; 994 | 995 | $user_id = $__TPOST['temple_id']; 996 | 997 | $user_metainfo = get_user_meta($user_id); 998 | 999 | $vendor_shop_name = $user_metainfo["pv_shop_name"][0]; 1000 | $vendor_address = $user_metainfo["description"][0]; 1001 | $vendor_name = $user_metainfo["nickname"][0]; 1002 | $vendor_email = $user_metainfo["billing_email"][0]; 1003 | $vendor_phone = $user_metainfo["billing_phone"][0]; 1004 | 1005 | $product_id = $__TPOST["prayerList_lights"][0]; 1006 | 1007 | $per_page = 20; 1008 | $args = array( 1009 | 'post_type' => 'product', 1010 | 'posts_per_page' => 3, 1011 | 'orderby' => 'ID', 1012 | 'order' => 'DESC', 1013 | 'author' => $user_id, 1014 | ); 1015 | $payment_status = "0"; 1016 | 1017 | // $product = mb_convert_encoding($product, "BIG5"); 1018 | 1019 | for($i=0; $i $product_id){ 1026 | $product_name = wc_get_product( $product_id )->get_title(); 1027 | $insert_val = "insert into [LightingDB].[dbo].[pendinglist] ( [Order_number], [Name], [phone], [vendor_address], [vendor_name], [product], [gender], [birthday], [order_date], [p_key_address], [payment_status], [vendor_location]) values ('".$order->id."',N'".$first_name."','".$__TPOST["mobile"]."','".$vendor_address."','".$vendor_name ."','" . $product_name . "','" .$gender."','" . $birthday . "','" . date("Y-m-d H:i:s") . "','" . $address_1 . "','" . $payment_status . "','" . $vendor_shop_name . "') "; 1028 | 1029 | error_log( $insert_val ); 1030 | // $res = mssql_query($insert_val); 1031 | } 1032 | 1033 | } 1034 | 1035 | } else { 1036 | 1037 | $insert_val = "UPDATE [LightingDB].[dbo].[pendinglist] SET payment_status = '1' WHERE Order_number='".$order_id."';"; 1038 | 1039 | error_log( $insert_val ); 1040 | // $res = mssql_query($insert_val); 1041 | 1042 | } 1043 | } 1044 | 1045 | function mysite_pending($order_id) { 1046 | error_log("$order_id set to PENDING"); 1047 | } 1048 | function mysite_failed($order_id) { 1049 | error_log("$order_id set to FAILED"); 1050 | } 1051 | function mysite_hold($order_id) { 1052 | error_log("$order_id set to ON HOLD"); 1053 | process_mssql_task($order_id, 0); 1054 | } 1055 | function mysite_processing($order_id) { 1056 | error_log("$order_id set to PROCESSING"); 1057 | } 1058 | function mysite_completed($order_id) { 1059 | error_log("$order_id set to COMPLETED"); 1060 | } 1061 | function mysite_refunded($order_id) { 1062 | error_log("$order_id set to REFUNDED"); 1063 | } 1064 | function mysite_cancelled($order_id) { 1065 | error_log("$order_id set to CANCELLED"); 1066 | } 1067 | function payment_completed($payment_status, $order_id) { 1068 | error_log("$order_id is in $payment_status status"); 1069 | if($payment_status == "processing") process_mssql_task($order_id, 0); 1070 | else if($payment_status == "completed") process_mssql_task($order_id, 1); 1071 | } 1072 | 1073 | add_action( 'woocommerce_order_status_pending', 'mysite_pending', 10, 1); 1074 | add_action( 'woocommerce_order_status_failed', 'mysite_failed', 10, 1); 1075 | add_action( 'woocommerce_order_status_on-hold', 'mysite_hold', 10, 1); 1076 | add_action( 'woocommerce_order_status_processing', 'mysite_processing', 10, 1); 1077 | add_action( 'woocommerce_order_status_completed', 'mysite_completed', 10, 1); 1078 | add_action( 'woocommerce_order_status_refunded', 'mysite_refunded', 10, 1); 1079 | add_action( 'woocommerce_order_status_cancelled', 'mysite_cancelled', 10, 1); 1080 | add_action( 'woocommerce_payment_complete_order_status', 'payment_completed', 10, 2); --------------------------------------------------------------------------------