PluginProbe
StoreEngine — Complete eCommerce Solution with Memberships, Licensing, Affiliates & More / 2.2.0
StoreEngine — Complete eCommerce Solution with Memberships, Licensing, Affiliates & More v2.2.0
2.3.0 2.2.0 2.1.1 2.1.0 2.0.0 1.10.0 1.9.1 1.9.0 1.2.1 1.2.2 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.0 All 59 releases
storeengine / includes / shortcode / order-billing-address.php

order-billing-address.php in StoreEngine — Complete eCommerce Solution with Memberships, Licensing, Affiliates & More 2.2.0, at includes/shortcode/order-billing-address.php

63 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace StoreEngine\Shortcode;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit;
7 }
8
9 use StoreEngine\Classes\Order;
10 use StoreEngine\Utils\Formatting;
11 use StoreEngine\Utils\Helper;
12 use StoreEngine\Utils\Template;
13 use WP_Error;
14
15 class OrderBillingAddress {
16
17 public function __construct() {
18 add_shortcode( 'storeengine_order_billing_address', [ $this, 'render' ] );
19 }
20
21 public function render( $atts ) {
22 $attributes = shortcode_atts( [
23 'dummy' => false,
24 ], $atts );
25 $dummy_order = Formatting::string_to_bool( $attributes['dummy'] );
26
27 if ( ! $dummy_order ) {
28 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
29 $order_hash = isset( $_GET['order_hash'] ) ? sanitize_text_field( wp_unslash( $_GET['order_hash'] ) ) : '';
30 $order = Helper::get_order_by_key( $order_hash );
31 $order = $order instanceof WP_Error ? false : $order;
32
33 // Fall back to sample content when there's no real order to show
34 // (page opened directly, previewed, or rendered in the editor).
35 if ( ! $order ) {
36 $dummy_order = true;
37 }
38 }
39
40 if ( $dummy_order ) {
41 $order = new Order();
42 $order->set_billing_first_name( 'John' );
43 $order->set_billing_last_name( 'Doe' );
44 $order->set_billing_address_1( 'Chuadanga Bus Stand, Abdur Razzak Complex' );
45 $order->set_billing_address_2( '4th Floor' );
46 $order->set_billing_city( 'Khulna' );
47 $order->set_billing_state( 'Jhenaidah' );
48 $order->set_billing_country( 'BD' );
49 $order->set_billing_email( 'support@storeengine.pro' );
50 $order->set_billing_phone( '01234567890123' );
51 $order->set_billing_company( 'KodeZen' );
52 $order->set_billing_postcode( '12345' );
53 }
54
55 ob_start();
56 Template::get_template( 'shortcode/order-billing-address.php', [
57 'order' => $order,
58 ] );
59
60 return ob_get_clean();
61 }
62 }
63