This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* add /blog segment to blog posts permalinks */ | |
function filter_post_link($permalink, $post) { | |
if ($post->post_type != 'post') | |
return $permalink; | |
return 'blog'.$permalink; | |
} | |
add_filter('pre_post_link', 'filter_post_link', 10, 2); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Shop Custom Permalinks | |
* Remove 'product' slug from Product permalink | |
* Remove 'product-category' slug from Product Category term link | |
* @author vovadevelopenko | |
*/ | |
defined( 'ABSPATH' ) || exit; | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
////// woo export add custom fields ////// | |
// add custom column headers | |
function wc_csv_export_modify_column_headers( $column_headers ) { | |
$new_headers = array( | |
'delivery_name' => 'Location', | |
'odel_date' => 'Date', | |
); | |
return array_merge( $column_headers, $new_headers ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//// wc order admin list custom field filter //// | |
function woo_orders_list_custom_filter($query) { | |
$post_type = !empty($_GET['post_type']) ? filter_input(INPUT_GET, 'post_type') : false; | |
$lctn = !empty($_GET['lctn']) ? filter_input(INPUT_GET, 'lctn') : false; | |
if (is_admin() && ($post_type == 'shop_order' && $query->is_main_query() && $lctn > 0)) { | |
$meta = $query->get('meta_query'); | |
$meta[] = array('key' => 'delivery_name', 'value' => $lctn, 'compare' => '='); | |
$query->set('meta_query', $meta); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// set subject | |
$subject = 'WC Send Mail Test'; | |
// load the mailer | |
$mailer = WC()->mailer(); | |
$mailer->send( get_option( 'admin_email' ), $subject, $mailer->wrap_message( $subject, 'a test message' ), '', '' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
////// Rename or remove order statuses ////// | |
function wc_renaming_order_status($order_statuses) { | |
$order_statuses = array( | |
'wc-pending' => _x('Pending', 'Order status', 'woocommerce'), | |
'wc-processing' => _x('New Order', 'Order status', 'woocommerce'), | |
'wc-cancelled' => _x('Cancelled', 'Order status', 'woocommerce'), | |
'wc-completed' => _x('Approved', 'Order status', 'woocommerce'), | |
'wc-on-hold' => _x('On Hold', 'Order status', 'woocommerce'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function getTermOrderedIds($post_type, $taxonomy) { | |
global $wpdb; | |
$sql = "SELECT p.ID FROM $wpdb->posts p | |
JOIN $wpdb->term_relationships tr ON (tr.object_id = p.ID) | |
JOIN $wpdb->term_taxonomy tt ON (tt.term_taxonomy_id = tr.term_taxonomy_id AND tt.taxonomy = '$taxonomy') | |
JOIN $wpdb->terms t ON (t.term_id = tt.term_id) | |
WHERE p.post_status = 'publish' AND post_type = '$post_type' ORDER BY t.name ASC"; | |
$res = $wpdb->get_results($sql); | |
if ($res) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action('wp_ajax_myCartDeliveryFee', 'myCartDeliveryFee'); | |
add_action('wp_ajax_nopriv_myCartDeliveryFee', 'myCartDeliveryFee'); | |
function myCartDeliveryFee() { | |
$fee = isset($_POST['delivery_fee']) && !empty($_POST['delivery_fee']) ? filter_input(INPUT_POST, 'delivery_fee') : 0; | |
session_start(); | |
$_SESSION['cart_fee_val'] = floatval(str_replace('$', '', $fee)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: WooCommerce Custom Payment Gateway | |
* Version: 1.0.0 | |
**/ | |
class WC_Other_Payment_Gateway extends WC_Payment_Gateway { | |
public function __construct() { | |
$this->id = 'other_payment'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Woo Custom Shipping Method | |
* Description: Custom Shipping Method for WooCommerce | |
* Version: 1.0.0 | |
*/ | |
if (!defined('WPINC')) { | |
die; | |
} |