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-shipping-address.php

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

65 lines 2.0 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 OrderShippingAddress {
16
17 public function __construct() {
18 add_shortcode( 'storeengine_order_shipping_address', [ $this, 'render' ] );
19 }
20
21 public function render( $atts ) {
22 $attributes = shortcode_atts( [ 'dummy' => false ], $atts );
23 $dummy_order = Formatting::string_to_bool( $attributes['dummy'] );
24
25 if ( ! $dummy_order ) {
26 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
27 $order_hash = isset( $_GET['order_hash'] ) ? sanitize_text_field( wp_unslash( $_GET['order_hash'] ) ) : '';
28 $order = Helper::get_order_by_key( $order_hash );
29 $order = $order instanceof WP_Error ? false : $order;
30
31 if ( ! $order ) {
32 // No order context at all — fall back to sample content so the
33 // page isn't blank (direct view, preview, or editor render).
34 $dummy_order = true;
35 } elseif ( ! $order->has_shipping_address() || $order->get_auto_complete_digital_order() ) {
36 // A real order that legitimately has no shipping address (e.g. a
37 // digital order) should still render nothing.
38 return '';
39 }
40 }
41
42 if ( $dummy_order ) {
43 $order = new Order();
44 $order->set_shipping_first_name( 'John' );
45 $order->set_shipping_last_name( 'Doe' );
46 $order->set_shipping_address_1( 'Chuadanga Bus Stand, Abdur Razzak Complex' );
47 $order->set_shipping_address_2( '4th Floor' );
48 $order->set_shipping_city( 'Khulna' );
49 $order->set_shipping_state( 'Jhenaidah' );
50 $order->set_shipping_country( 'BD' );
51 $order->set_shipping_email( 'support@storeengine.pro' );
52 $order->set_shipping_phone( '01234567890123' );
53 $order->set_shipping_company( 'Kodezen' );
54 $order->set_shipping_postcode( '7300' );
55 }
56
57 ob_start();
58 Template::get_template( 'shortcode/order-shipping-address.php', [
59 'order' => $order,
60 ] );
61
62 return ob_get_clean();
63 }
64 }
65