-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwc-digital-checkout.php
80 lines (74 loc) · 2.55 KB
/
wc-digital-checkout.php
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
69
70
71
72
73
74
75
76
77
78
79
80
<?php
/*
Plugin Name: Digital Checkout for WooCommerce
Plugin URI: https://wordpress.org/plugins/wc-digital-checkout/
Description: WooCommerce Fast checkout on digital products
Version: 3
Author: MihanWP
Author URI: https://mihanwp.com
License: GPLv2
*/
add_filter( 'woocommerce_checkout_fields' , 'mihanwp_custom_override_checkout_fields' );
function mihanwp_custom_override_checkout_fields( $fields ) {
global $woocommerce;
$hasPhysicalProduct = false;
if ( ! empty( $woocommerce->cart->cart_contents ) ) {
$cart = $woocommerce->cart->get_cart();
foreach ( $cart as $key => $values ) {
$_product = get_product( $values['variation_id'] ? $values['variation_id'] : $values['product_id'] );
if ( ! empty( $_product ) && $_product->exists() && $values['quantity'] > 0 ) {
if ($_product->virtual == 'no') {
$hasPhysicalProduct = true;
}
}
}
}
if ($hasPhysicalProduct == false)
{
unset($fields['billing']['billing_address_1']);
unset($fields['billing']['billing_address_2']);
unset($fields['billing']['billing_company']);
unset($fields['billing']['billing_city']);
unset($fields['billing']['billing_postcode']);
unset($fields['billing']['billing_country']);
unset($fields['billing']['billing_state']);
unset($fields['billing']['billing_phone']);
wp_enqueue_style( 'myCSS', plugins_url( 'style.css', __FILE__ ) );
}
return $fields;
}
function mihanwp_custom_override_billing_fields( $fields ) {
unset($fields['billing_state']);
unset($fields['billing_country']);
unset($fields['billing_address_1']);
unset($fields['billing_address_2']);
unset($fields['billing_postcode']);
unset($fields['billing_city']);
$fields['billing_phone']['required'] = false;
return $fields;
}
function mihanwp_custom_override_shipping_fields( $fields ) {
unset($fields['shipping_state']);
unset($fields['shipping_country']);
unset($fields['shipping_company']);
unset($fields['shipping_address_1']);
unset($fields['shipping_address_2']);
unset($fields['shipping_postcode']);
unset($fields['shipping_city']);
return $fields;
}
function mihanwp_custom_override_account_page_addresses($fields) {
unset($fields['address_1']);
unset($fields['address_2']);
unset($fields['city']);
unset($fields['state']);
unset($fields['postcode']);
unset($fields['country']);
return $fields;
}
function mihanwp_custom_override_account_page_address_title() {
return 'My Informations';
}
function mihanwp_custom_override_account_page_address_description() {
return 'Its your profile informations.';
}