billing-form-fields.php
1 week ago
billing.php
3 weeks ago
cart.php
10 months ago
checkout-billing-form-fields.php
3 weeks ago
checkout-details.php
3 weeks ago
checkout.php
3 weeks ago
order-placement-failed.php
9 months ago
order-placement-success.php
3 weeks ago
billing-form-fields.php
163 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Billing Address Form Fields |
| 4 | * |
| 5 | * @package Tutor\Templates |
| 6 | * @author Themeum <support@themeum.com> |
| 7 | * @link https://themeum.com |
| 8 | * @since 4.0.0 |
| 9 | * |
| 10 | * Received data |
| 11 | * - $show_close_button |
| 12 | * - $close_action |
| 13 | * - $country_options |
| 14 | * - $initial_states |
| 15 | */ |
| 16 | |
| 17 | defined( 'ABSPATH' ) || exit; |
| 18 | |
| 19 | use Tutor\Components\Button; |
| 20 | use Tutor\Components\SvgIcon; |
| 21 | use Tutor\Components\Constants\Color; |
| 22 | use Tutor\Components\Constants\Size; |
| 23 | use Tutor\Components\Constants\Variant; |
| 24 | use Tutor\Components\Constants\InputType; |
| 25 | use Tutor\Components\InputField; |
| 26 | use TUTOR\Icon; |
| 27 | |
| 28 | $show_close_button = $show_close_button ?? false; |
| 29 | $close_action = $close_action ?? 'editBilling = false'; |
| 30 | $country_options = $country_options ?? array(); |
| 31 | $initial_states = $initial_states ?? array(); |
| 32 | ?> |
| 33 | |
| 34 | <?php if ( $show_close_button ) : ?> |
| 35 | <div class="tutor-flex tutor-items-center tutor-justify-between tutor-mb-4"> |
| 36 | <div class="tutor-flex tutor-items-center tutor-gap-2"> |
| 37 | <span class="tutor-icon tutor-icon-md tutor-text-primary"> |
| 38 | <?php |
| 39 | SvgIcon::make() |
| 40 | ->name( Icon::MAP_PIN ) |
| 41 | ->color( Color::BRAND ) |
| 42 | ->size( 20 ) |
| 43 | ->render(); |
| 44 | ?> |
| 45 | </span> |
| 46 | <div class="tutor-medium tutor-mb-none tutor-font-semibold"> |
| 47 | <?php echo esc_html__( 'Billing Address', 'tutor' ); ?> |
| 48 | </div> |
| 49 | </div> |
| 50 | <?php |
| 51 | Button::make() |
| 52 | ->variant( Variant::LINK ) |
| 53 | ->size( Size::SMALL ) |
| 54 | ->label( __( 'Close', 'tutor' ) ) |
| 55 | ->attr( 'type', 'button' ) |
| 56 | ->attr( '@click', "{$close_action}" ) |
| 57 | ->render(); |
| 58 | ?> |
| 59 | </div> |
| 60 | <?php endif; ?> |
| 61 | |
| 62 | <div class="tutor-grid tutor-md-grid-cols-1 tutor-grid-cols-2 tutor-gap-5"> |
| 63 | <?php |
| 64 | InputField::make() |
| 65 | ->name( 'billing_first_name' ) |
| 66 | ->label( __( 'First Name', 'tutor' ) ) |
| 67 | ->id( 'billing_first_name' ) |
| 68 | ->required() |
| 69 | ->placeholder( __( 'Enter your first name', 'tutor' ) ) |
| 70 | ->attr( 'x-bind', "register('billing_first_name', { required: true })" ) |
| 71 | ->render(); |
| 72 | |
| 73 | InputField::make() |
| 74 | ->name( 'billing_last_name' ) |
| 75 | ->label( __( 'Last Name', 'tutor' ) ) |
| 76 | ->id( 'billing_last_name' ) |
| 77 | ->required() |
| 78 | ->placeholder( __( 'Enter your last name', 'tutor' ) ) |
| 79 | ->attr( 'x-bind', "register('billing_last_name', { required: true })" ) |
| 80 | ->render(); |
| 81 | ?> |
| 82 | </div> |
| 83 | |
| 84 | <?php |
| 85 | InputField::make() |
| 86 | ->type( InputType::EMAIL ) |
| 87 | ->name( 'billing_email' ) |
| 88 | ->label( __( 'Email Address', 'tutor' ) ) |
| 89 | ->id( 'billing_email' ) |
| 90 | ->required() |
| 91 | ->placeholder( __( 'Enter your email address', 'tutor' ) ) |
| 92 | ->attr( 'x-bind', "register('billing_email', { required: true })" ) |
| 93 | ->render(); |
| 94 | |
| 95 | InputField::make() |
| 96 | ->name( 'billing_phone' ) |
| 97 | ->label( __( 'Phone', 'tutor' ) ) |
| 98 | ->id( 'billing_phone' ) |
| 99 | ->required() |
| 100 | ->placeholder( __( 'Enter your phone number', 'tutor' ) ) |
| 101 | ->attr( 'x-bind', "register('billing_phone', { required: true })" ) |
| 102 | ->render(); |
| 103 | |
| 104 | InputField::make() |
| 105 | ->type( InputType::SELECT ) |
| 106 | ->name( 'billing_country' ) |
| 107 | ->label( __( 'Country', 'tutor' ) ) |
| 108 | ->options( $country_options ) |
| 109 | ->searchable() |
| 110 | ->id( 'billing_country' ) |
| 111 | ->required() |
| 112 | ->placeholder( __( 'Enter your country', 'tutor' ) ) |
| 113 | ->attr( 'x-bind', "register('billing_country', { required: true })" ) |
| 114 | ->render(); |
| 115 | |
| 116 | InputField::make() |
| 117 | ->type( InputType::SELECT ) |
| 118 | ->name( 'billing_state' ) |
| 119 | ->label( __( 'State', 'tutor' ) ) |
| 120 | ->options( $initial_states ) |
| 121 | ->searchable() |
| 122 | ->id( 'billing_state' ) |
| 123 | ->placeholder( __( 'Enter your state', 'tutor' ) ) |
| 124 | ->attr( 'x-effect', 'options = (config.stateOptions || {})[values.billing_country] || []' ) |
| 125 | ->render(); |
| 126 | ?> |
| 127 | |
| 128 | <!-- City & Postcode Row --> |
| 129 | <div class="tutor-grid tutor-md-grid-cols-1 tutor-grid-cols-2 tutor-gap-5"> |
| 130 | <?php |
| 131 | InputField::make() |
| 132 | ->name( 'billing_city' ) |
| 133 | ->label( __( 'City', 'tutor' ) ) |
| 134 | ->id( 'billing_city' ) |
| 135 | ->required() |
| 136 | ->placeholder( __( 'Enter your city', 'tutor' ) ) |
| 137 | ->attr( 'x-bind', "register('billing_city', { required: true })" ) |
| 138 | ->render(); |
| 139 | |
| 140 | InputField::make() |
| 141 | ->name( 'billing_zip_code' ) |
| 142 | ->label( __( 'Postcode/ Zip', 'tutor' ) ) |
| 143 | ->id( 'billing_zip_code' ) |
| 144 | ->required() |
| 145 | ->placeholder( __( 'Enter your postcode/ zip', 'tutor' ) ) |
| 146 | ->attr( 'x-bind', "register('billing_zip_code', { required: true })" ) |
| 147 | ->render(); |
| 148 | ?> |
| 149 | </div> |
| 150 | |
| 151 | <!-- Address --> |
| 152 | <?php |
| 153 | InputField::make() |
| 154 | ->type( InputType::TEXTAREA ) |
| 155 | ->name( 'billing_address' ) |
| 156 | ->label( __( 'Address', 'tutor' ) ) |
| 157 | ->id( 'billing_address' ) |
| 158 | ->required() |
| 159 | ->placeholder( __( 'Enter your address', 'tutor' ) ) |
| 160 | ->attr( 'x-bind', "register('billing_address', { required: true })" ) |
| 161 | ->render(); |
| 162 | ?> |
| 163 |