public function get_invoice($the_invoice = false, $type = 'simple') { global $post; if (false === $the_invoice) { $types = wc_gzdp_get_invoice_types($type); $args = array('post_status' => 'auto-draft', 'post_type' => 'invoice', 'post_title' => sprintf(__('New %s', 'woocommerce-germanized-pro'), $types['title'])); $the_invoice = wp_insert_post($args); if (!is_wp_error($the_invoice)) { update_post_meta($the_invoice, '_type', $type); } } if (is_numeric($the_invoice)) { $the_invoice = get_post($the_invoice); } if (!$the_invoice || !is_object($the_invoice)) { return false; } $invoice_id = absint($the_invoice->ID); $invoice_type = get_post_meta($the_invoice->ID, '_type', true) ? get_post_meta($the_invoice->ID, '_type', true) : 'simple'; $classname = false; if ($invoice_type = wc_gzdp_get_invoice_types($invoice_type)) { $classname = $invoice_type['class_name']; } if (!class_exists($classname)) { $classname = 'WC_GZDP_Invoice_Simple'; } return new $classname($the_invoice); }
function wc_gzdp_get_next_invoice_number($type) { $types = wc_gzdp_get_invoice_types(); if (!isset($types[$type])) { return false; } if ($type == 'cancellation' && get_option('woocommerce_gzdp_invoice_cancellation_numbering') == 'no') { $type = 'simple'; } $cur = get_option('wc_gzdp_invoice_' . $type) ? absint(get_option('wc_gzdp_invoice_' . $type)) : 0; update_option('wc_gzdp_invoice_' . $type, ++$cur); return $cur; }
public function get_export_data(WC_GZDP_Invoice $invoice) { $type = wc_gzdp_get_invoice_types($invoice->type); $totals = $invoice->totals; $status = ''; foreach (wc_gzdp_get_invoice_statuses() as $key => $val) { if ($key == $invoice->get_status()) { $status = $val; } } $return = array('type' => $type['title'], 'date' => $invoice->get_date(get_option('woocommerce_gzdp_invoice_date_format')), 'delivered' => $invoice->is_delivered() ? $invoice->get_delivery_date() : __('no'), 'status' => $status); foreach ($totals as $key => $total) { $return[$key] = $total; } foreach ($this->metas as $meta) { $return[$meta] = $invoice->{$meta}; } return $invoice->filter_export_data($return); }
public function add_meta_boxes() { global $post; $order = wc_get_order($post); $invoices = wc_gzdp_get_invoices_by_order($order); if (!empty($invoices)) { foreach ($invoices as $id => $invoice) { $theinvoice = $invoice; if (!($classname = $this->get_meta_box_class($invoice->type))) { continue; } add_meta_box('woocommerce-invoice-' . $invoice->id, $invoice->get_title(), $classname . '::output', 'shop_order', 'normal', 'high', array('invoice' => $theinvoice)); if ($invoice->type == 'simple' && !$invoice->is_cancellation() && !$invoice->is_cancelled()) { $theinvoice = wc_gzdp_get_invoice(false, 'cancellation'); $theinvoice->set_parent($invoice->id); // Add new Cancellation add_meta_box('woocommerce-invoice-cancellation-new', sprintf(__('Cancel %s', 'woocommerce-germanized-pro'), $invoice->get_title()), 'WC_GZDP_Meta_Box_Invoice::output', 'shop_order', 'normal', 'high', array('invoice' => $theinvoice)); } } } foreach (wc_gzdp_get_invoice_types() as $type => $values) { if (wc_gzdp_order_has_invoice_type($order, $type)) { continue; } if ($values['manual'] || !($classname = $this->get_meta_box_class($type))) { continue; } $theinvoice = wc_gzdp_get_invoice(false, $type); // Add new Invoice add_meta_box('woocommerce-invoice-' . $theinvoice->type . '-new', $values['title_new'], $classname . '::output', 'shop_order', 'normal', 'high', array('invoice' => $theinvoice)); } }
export_date_options('invoice'); ?> </select> </li> <li> <label><?php echo _x('Typ:', 'invoices', 'woocommerce-germanized-pro'); ?> </label> <select name="invoice_type"> <option value="0"><?php echo _x('All', 'invoices', 'woocommerce-germanized-pro'); ?> </option> <?php foreach (wc_gzdp_get_invoice_types() as $type => $label) { ?> <option value="<?php echo $type; ?> "><?php echo $label['title']; ?> </option> <?php } ?> </select> </li> <li> <label><?php
public function get_title_pdf() { $type = wc_gzdp_get_invoice_types($this->type); return '<span class="invoice-desc">' . $type['title'] . '</span>'; }