-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwoocommerce-notes.php
More file actions
68 lines (51 loc) · 2.32 KB
/
woocommerce-notes.php
File metadata and controls
68 lines (51 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
//update order status
$order->update_status('completed');
//cart url
echo $woocommerce->cart->get_cart_url();
wc_customer_edit_account_url();
//add options to sort
add_filter('woocommerce_get_catalog_ordering_args', 'custom_woocommerce_get_catalog_ordering_args');
function custom_woocommerce_get_catalog_ordering_args($args) {
$orderby_value = isset($_GET['orderby']) ? woocommerce_clean($_GET['orderby']) : apply_filters('woocommerce_default_catalog_orderby', get_option('woocommerce_default_catalog_orderby'));
if ('sku' == $orderby_value) {
$args['orderby'] = 'meta_value';
$args['order'] = 'asc';
$args['meta_key'] = '_sku';
}
return $args;
}
add_filter('woocommerce_default_catalog_orderby_options', 'custom_woocommerce_catalog_orderby');
add_filter('woocommerce_catalog_orderby', 'custom_woocommerce_catalog_orderby');
function custom_woocommerce_catalog_orderby($sortby) {
$sortby['sku'] = 'Sort by sku';
return $sortby;
}
//remove price
remove_action('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10);
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_price', 10);
remove_action('woocommerce_single_product_lightbox_summary', 'woocommerce_template_single_price', 10);
//remove add to cart
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30);
remove_action('woocommerce_simple_add_to_cart', 'woocommerce_simple_add_to_cart', 30);
remove_action('woocommerce_grouped_add_to_cart', 'woocommerce_grouped_add_to_cart', 30);
remove_action('woocommerce_variable_add_to_cart', 'woocommerce_variable_add_to_cart', 30);
remove_action('woocommerce_external_add_to_cart', 'woocommerce_external_add_to_cart', 30);
remove_action('woocommerce_single_product_lightbox_summary', 'woocommerce_template_single_add_to_cart', 30);
$order->add_order_note(
sprintf(
"Shipping label available at: '%s'", $shipment->postage_label->label_url
)
);
//get add to cart form
woocommerce_simple_add_to_cart();
add_filter ('add_to_cart_redirect', 'redirect_to_checkout');
function redirect_to_checkout() {
global $woocommerce;
$checkout_url = $woocommerce->cart->get_checkout_url();
return $checkout_url;
}
//notice
wc_add_notice();
wc_notice_count('error');
wc_print_notices();