-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
109 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
* @author Paul Kilmurray <[email protected]> | ||
* | ||
* @see http://wcpos.com | ||
* @package WooCommercePOS\Templates | ||
*/ | ||
|
||
namespace WCPOS\WooCommercePOS\Templates; | ||
|
@@ -19,26 +20,27 @@ class Received { | |
public function __construct( int $order_id ) { | ||
$this->order_id = $order_id; | ||
|
||
add_filter('show_admin_bar', '__return_false'); | ||
add_filter( 'show_admin_bar', '__return_false' ); | ||
} | ||
|
||
|
||
public function get_template(): void { | ||
try { | ||
// get order | ||
$order = wc_get_order( $this->order_id ); | ||
$order = \wc_get_order( $this->order_id ); | ||
|
||
// Order or receipt url is invalid. | ||
if ( ! $order ) { | ||
wp_die( esc_html__( 'Sorry, this order is invalid.', 'woocommerce-pos' ) ); | ||
} | ||
|
||
// if ( ! $order->is_paid() ) { | ||
// wp_die( esc_html__( 'Sorry, this order has not been paid.', 'woocommerce-pos' ) ); | ||
// } | ||
// if ( ! $order->is_paid() ) { | ||
// wp_die( esc_html__( 'Sorry, this order has not been paid.', 'woocommerce-pos' ) ); | ||
// } | ||
|
||
/** | ||
* @TODO - this is a hack and needs to be fixed | ||
* @NOTE - the received template will be removed once we move to session based checkout | ||
* | ||
* - hardcoding the rest endpoint is a receipe for disaster | ||
*/ | ||
|
@@ -53,7 +55,7 @@ public function get_template(): void { | |
include woocommerce_pos_locate_template( 'received.php' ); | ||
exit; | ||
} catch ( Exception $e ) { | ||
wc_print_notice( $e->getMessage(), 'error' ); | ||
\wc_print_notice( $e->getMessage(), 'error' ); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,13 +16,11 @@ | |
* @author Paul Kilmurray <[email protected]> | ||
* | ||
* @see http://wcpos.com | ||
* @package WooCommercePOS | ||
*/ | ||
|
||
namespace WCPOS\WooCommercePOS; | ||
|
||
use function define; | ||
use Dotenv\Dotenv; | ||
|
||
// Define plugin constants. | ||
const VERSION = '1.4.0-beta.3'; | ||
const PLUGIN_NAME = 'woocommerce-pos'; | ||
|
@@ -31,36 +29,65 @@ | |
\define( __NAMESPACE__ . '\PLUGIN_PATH', trailingslashit( plugin_dir_path( __FILE__ ) ) ); | ||
\define( __NAMESPACE__ . '\PLUGIN_URL', trailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) ); | ||
|
||
// minimum requirements | ||
// minimum requirements. | ||
const WC_MIN_VERSION = '5.3'; | ||
const PHP_MIN_VERSION = '7.4'; | ||
const MIN_PRO_VERSION = '1.2.0'; | ||
|
||
// Autoloader | ||
// load .env flags (for development). | ||
function load_env( $file ) { | ||
if ( ! file_exists( $file ) ) { | ||
return; | ||
} | ||
|
||
$lines = file( $file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES ); | ||
foreach ( $lines as $line ) { | ||
if ( strpos( trim( $line ), '#' ) === 0 ) { | ||
continue; | ||
} | ||
|
||
list($name, $value) = explode( '=', $line, 2 ); | ||
$name = trim( $name ); | ||
$value = trim( $value ); | ||
|
||
if ( ! array_key_exists( $name, $_SERVER ) && ! array_key_exists( $name, $_ENV ) ) { | ||
putenv( sprintf( '%s=%s', $name, $value ) ); | ||
$_ENV[ $name ] = $value; | ||
} | ||
} | ||
} | ||
|
||
// Autoloader. | ||
if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) { | ||
require_once __DIR__ . '/vendor/autoload.php'; | ||
|
||
// Environment variables. | ||
Dotenv::createImmutable( __DIR__ )->safeLoad(); | ||
load_env( __DIR__ . '/.env' ); | ||
|
||
// Activate plugin | ||
// Activate plugin. | ||
new Activator(); | ||
|
||
// Deactivate plugin | ||
// Deactivate plugin. | ||
new Deactivator(); | ||
} else { | ||
add_action( 'admin_notices', function(): void { | ||
?> | ||
add_action( | ||
'admin_notices', | ||
function (): void { | ||
?> | ||
<div class="notice notice-error"> | ||
<p><?php esc_html_e( 'The WooCommerce POS plugin failed to load correctly.', 'woocommerce-pos' ); ?></p> | ||
</div> | ||
<?php | ||
} ); | ||
<?php | ||
} | ||
); | ||
} | ||
|
||
// Declare HPOS compatible | ||
add_action( 'before_woocommerce_init', function(): void { | ||
if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) { | ||
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true ); | ||
// Declare HPOS compatible. | ||
add_action( | ||
'before_woocommerce_init', | ||
function (): void { | ||
if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) { | ||
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true ); | ||
} | ||
} | ||
} ); | ||
); |