public static function enforce_non_guest_orders($post_id, $post) { // must be shop order if ($post->post_type != 'shop_order') { return; } // if guest checkout is active, this does not apply if (get_option('woocommerce_enable_guest_checkout', 'no') == 'yes') { return; } // restrict for everyone except those who can manage woocommerce settings (ie: administrators) if (current_user_can('manage_woocommerce')) { return; } // if the guest checkout is disabled and the admin is attempting to use a guest user, then flag the order, which is later used to limit payment and pop an error if (isset($_POST['customer_user'])) { $current = get_post_meta($post_id, '_customer_user', true); if (empty($current)) { update_post_meta($post_id, '_use_guest_attempted', 1); self::_remove_recursive_filters(); self::_disable_emails(); do_action('qsot-before-guest-check-update-order-status', $post); if (QSOT::is_wc_latest()) { $order = wc_get_order($post_id); $ostatus = $order->get_status(); } else { $order = new WC_Order($post_id); $stati = wp_get_object_terms(array($post_id), array('shop_order_status'), 'slugs'); $ostatus = substr($ostatus = current($stati), 0, 3) == 'wc-' ? substr($ostatus, 3) : $ostatus; } if ($ostatus != 'pending') { $order->update_status('pending', __('You cannot use "Guest" as the owner of the order, due to current Woocommerce settings.', 'opentickets-community-edition')); } else { $order->add_order_note(__('You cannot use "Guest" as the owner of the order, due to current Woocommerce settings.', 'opentickets-community-edition')); } self::_enable_emails(); } else { update_post_meta($post_id, '_use_guest_attempted', 0); } } }
public static function aaj_ts_update_order_items($resp, $data) { $resp['s'] = false; $resp['e'] = array(); $oid = $data['order_id']; if ($oid > 0) { $order = new WC_Order($oid); $resp['i'] = array(); $resp['s'] = true; foreach ($order->get_items(array('line_item', 'fee')) as $item_id => $item) { $out = ''; ob_start(); $class = apply_filters('woocommerce_admin_order_items_class', 'new_row', $item, $order); switch ($item['type']) { case 'line_item': $_product = $order->get_product_from_item($item); $template = QSOT::is_wc_latest() ? 'meta-boxes/views/html-order-item.php' : 'post-types/meta-boxes/views/html-order-item.php'; include apply_filters('qsot-woo-template', $template, 'admin'); break; case 'fee': $template = QSOT::is_wc_latest() ? 'meta-boxes/views/html-order-fee.php' : 'post-types/meta-boxes/views/html-order-fee.php'; include apply_filters('qsot-woo-template', $template, 'admin'); break; case 'shipping': $template = QSOT::is_wc_latest() ? 'meta-boxes/views/html-order-shipping.php' : 'post-types/meta-boxes/views/html-order-shipping.php'; include apply_filters('qsot-woo-template', $template, 'admin'); break; } do_action('woocommerce_order_item_' . $item['type'] . '_html'); $out = trim(ob_get_contents()); ob_end_clean(); $resp['i'][] = $out; } } else { $resp['e'][] = __('Invalid order number.', 'opentickets-community-edition'); } return $resp; }
protected static function _order_item_order_status($item_id) { global $wpdb; $q = $wpdb->prepare('select order_id from ' . $wpdb->prefix . 'woocommerce_order_items where order_item_id = %d', $item_id); $order_id = (int) $wpdb->get_var($q); if ($order_id <= 0) { return 'does-not-exist'; } if (QSOT::is_wc_latest()) { $status = preg_replace('#^wc-#', '', get_post_status($order_id)); } else { $status = wp_get_object_terms(array($order_id), array('shop_order_status'), 'slugs'); $status = is_array($status) ? in_array('completed', $status) ? 'completed' : current($status) : 'does-no-exist'; } return $status; }
<?php if (QSOT::is_wc_latest()) { _deprecated_file(__FILE__, 'OTv1.5', dirname(dirname(dirname(dirname(__FILE__)))) . '/meta-boxes/views/html-order-item.php', __('OpenTickets WC template override has moved location.', 'opentickets-community-edition')); } include dirname(dirname(dirname(dirname(__FILE__)))) . '/meta-boxes/views/html-order-item.php';