BillingAddress.php
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Give\Framework\FieldsAPI; |
| 6 | |
| 7 | /** |
| 8 | * @since 3.0.0 |
| 9 | */ |
| 10 | class BillingAddress extends Group |
| 11 | { |
| 12 | const TYPE = 'billingAddress'; |
| 13 | |
| 14 | /** |
| 15 | * @since 3.0.0 |
| 16 | */ |
| 17 | public $apiUrl; |
| 18 | |
| 19 | /** |
| 20 | * @since 3.0.0 |
| 21 | */ |
| 22 | public $groupLabel; |
| 23 | |
| 24 | /** |
| 25 | * @since 3.0.0 |
| 26 | */ |
| 27 | public function setApiUrl(string $url): BillingAddress |
| 28 | { |
| 29 | $this->apiUrl = $url; |
| 30 | |
| 31 | return $this; |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * @since 3.0.0 |
| 36 | */ |
| 37 | public function setGroupLabel(string $groupLabel): BillingAddress |
| 38 | { |
| 39 | $this->groupLabel = $groupLabel; |
| 40 | |
| 41 | return $this; |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * @since 3.0.0 |
| 46 | * |
| 47 | * @throws Exceptions\EmptyNameException|Exceptions\NameCollisionException |
| 48 | */ |
| 49 | public static function make($name): BillingAddress |
| 50 | { |
| 51 | return parent::make($name) |
| 52 | ->append( |
| 53 | Select::make('country') |
| 54 | ->label(__('Country', 'give')) |
| 55 | ->options([ |
| 56 | ['value', 'label'], |
| 57 | ]), |
| 58 | |
| 59 | Text::make('address1') |
| 60 | ->label(__('Address Line 1', 'give')), |
| 61 | |
| 62 | Text::make('address2') |
| 63 | ->label(__('Address Line 2', 'give')), |
| 64 | |
| 65 | Text::make('city') |
| 66 | ->label(__('City', 'give')), |
| 67 | |
| 68 | Hidden::make('state') |
| 69 | ->label(__('State/Province/Country', 'give')), |
| 70 | |
| 71 | Text::make('zip') |
| 72 | ->label(__('Zip/Postal Code', 'give')) |
| 73 | ); |
| 74 | } |
| 75 | } |
| 76 |