CartSchema::IDENTIFIER, 'namespace' => 'shipclock-pre-orders', 'data_callback' => array( __CLASS__, 'cart_data' ), 'schema_callback' => array( __CLASS__, 'cart_schema' ), 'schema_type' => ARRAY_A, ) ); } /** * Data. * * @return array */ public static function cart_data() { $later = POKIT_Cart::due_later(); return array( 'has_preorder' => POKIT_Cart::has_preorder(), 'place_order_text' => (string) pokit_opt( 'place_order_text' ), 'due_later' => $later, 'due_later_html' => $later > 0 ? html_entity_decode( wp_strip_all_tags( wc_price( $later ) ), ENT_QUOTES, 'UTF-8' ) : '', ); } /** * Schema. * * @return array */ public static function cart_schema() { return array( 'has_preorder' => array( 'type' => 'boolean', 'context' => array( 'view', 'edit' ), 'readonly' => true, ), 'place_order_text' => array( 'type' => 'string', 'context' => array( 'view', 'edit' ), 'readonly' => true, ), 'due_later' => array( 'type' => 'number', 'context' => array( 'view', 'edit' ), 'readonly' => true, ), 'due_later_html' => array( 'type' => 'string', 'context' => array( 'view', 'edit' ), 'readonly' => true, ), ); } /** * Script for the Checkout block. */ public static function script() { if ( ! ( is_checkout() || is_cart() ) || ! wp_script_is( 'wc-blocks-checkout', 'registered' ) ) { return; } wp_enqueue_script( 'pokit-blocks-checkout', POKIT_URL . 'assets/js/blocks-checkout.js', array( 'wc-blocks-checkout', 'wp-plugins', 'wp-element', 'wp-data' ), POKIT_VERSION, true ); wp_localize_script( 'pokit-blocks-checkout', 'pokitBlocks', array( 'dueLabel' => __( 'Due on release', 'shipclock-pre-orders' ), 'dueHelp' => __( 'We will email you a secure payment link when your pre-order is ready.', 'shipclock-pre-orders' ), ) ); } }