Skip to content

Commit

Permalink
Merge branch 'release/1.2.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
nurul-umbhiya committed Sep 16, 2023
2 parents f6d76fb + b821188 commit 50f9238
Show file tree
Hide file tree
Showing 6 changed files with 1,139 additions and 658 deletions.
6 changes: 6 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
====== Changelog ======

v1.2.2 -> 16 Sep 2023
------------------------
- **Update:** WordPress 6.3.1 compatibility
- **Update:** Added HPOS (High Performance Order Storage) support

v1.2.1 -> 22 May 2021
------------------------
- [new] Added new filter hook: dokan_invoice_single_seller_address
Expand Down
51 changes: 31 additions & 20 deletions dokan-invoice.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?php
/**
* Plugin Name: Dokan - PDF Invoice
* Plugin URI: https://wedevs.com/
* Plugin URI: https://dokan.co/wordpress/
* Description: A Dokan plugin Add-on to get PDF invoice.
* Version: 1.2.1
* Version: 1.2.2
* Author: weDevs
* Author URI: https://wedevs.com/
* Author URI: https://dokan.co/
* License: GPL2
* Text Domain: dokan-invoice
* WC requires at least: 3.0
* WC tested up to: 5.3.0
* WC requires at least: 5.0.0
* WC tested up to: 8.1.0
*/

/**
Expand Down Expand Up @@ -74,18 +74,32 @@ public function __construct() {

$this->depends_on['dokan'] = array(
'name' => 'WeDevs_Dokan',
'notice' => sprintf( __( '<b>Dokan PDF Invoice </b> requires %sDokan plugin%s to be installed & activated!' , 'dokan-invoice' ), '<a target="_blank" href="https://wedevs.com/products/plugins/dokan/">', '</a>' ),
'notice' => sprintf( __( '<b>Dokan PDF Invoice </b> requires %sDokan plugin%s to be installed & activated!' , 'dokan-invoice' ), '<a target="_blank" href="https://dokan.co/wordpress/">', '</a>' ),
);

$this->depends_on['woocommerce_pdf_invoices'] = array(
'name' => 'WooCommerce_PDF_Invoices',
'notice' => sprintf( __( '<b>Dokan PDF Invoice </b> requires %sWooCommerce PDF Invoices & packing slips plugin%s to be installed & activated!' , 'dokan-invoice' ), '<a target="_blank" href="https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/">', '</a>' ),
);

add_action( 'before_woocommerce_init', [ $this, 'add_hpos_support' ] );
add_action( 'init', array( $this,'is_dependency_available') );
add_action( 'plugins_loaded', array( $this, 'init_hooks' ) );
}

/**
* Add High Performance Order Storage Support.
*
* @since 1.2.2
*
* @return void
*/
public function add_hpos_support() {
if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
}
}

/**
* check if dependencies installed or not and add error notice
*
Expand Down Expand Up @@ -186,21 +200,14 @@ public function enqueue_scripts() {
* Hooked with WP_invoice filter
*
* @param array $actions
* @param obj $order
* @param WC_Order $order
*
* @return array $actions
*/
public function dokan_invoice_listing_actions_my_account( $actions, $order ) {
$order_id = dokan_get_prop( $order, 'id' );
$order_status = dokan_get_prop( $order, 'status' );
if ( get_post_meta( $order_id, '_wcpdf_invoice_exists', true ) || in_array( $order_status, apply_filters( 'wpo_wcpdf_myaccount_allowed_order_statuses', array() ) ) ) {
$actions[ 'invoice' ] = array(
'url' => wp_nonce_url( admin_url( 'admin-ajax.php?action=generate_wpo_wcpdf&my-account&template_type=invoice&order_ids=' . $order_id ), 'generate_wpo_wcpdf' ),
'name' => apply_filters( 'dokan_invoice_myaccount_button_text', __( 'Download invoice (PDF)', 'dokan-invoice' ) )
);
}
$frontend = new \WPO\WC\PDF_Invoices\Frontend();

return $actions;
return $frontend->my_account_pdf_link( $actions, $order );
}

/**
Expand Down Expand Up @@ -310,7 +317,7 @@ public function wpo_wcpdf_dokan_privs( $allowed, $order_ids ) {

if ( count( $order_ids ) == 1 ) {

$order = new WC_Order( $order_ids );
$order = wc_get_order( $order_ids );
$items = $order->get_items();
$seller_id = dokan_get_seller_id_by_order( $order_ids );
$current_user = get_current_user_id();
Expand Down Expand Up @@ -355,16 +362,20 @@ public function get_order_id_parent_id( $document = null ) {
if (empty($document) || empty($document->order)) {
// PDF Invoice 1.X backwards compatibility
global $wpo_wcpdf;
/**
* @var $order WC_Order
*/
$order = $wpo_wcpdf->export->order;
$order_id = dokan_get_prop( $order, 'id' );
$parent_id = wp_get_post_parent_id( $order_id );
$order_id = $order->get_id();
$parent_id = $order->get_parent_id();
} else {
if ( $document->is_refund( $document->order ) ) {
$order_id = $document->get_refund_parent_id( $document->order );
} else {
$order_id = $document->order_id;
}
$parent_id = wp_get_post_parent_id( $order_id );
$order = wc_get_order( $order_id );
$parent_id = $order->get_parent_id();
}

return compact('order_id','parent_id');
Expand Down
18 changes: 7 additions & 11 deletions languages/dokan-invoice.pot
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Copyright (C) 2021 weDevs
# Copyright (C) 2023 weDevs
# This file is distributed under the GPL2.
msgid ""
msgstr ""
"Project-Id-Version: Dokan - PDF Invoice 1.2.1\n"
"Project-Id-Version: Dokan - PDF Invoice 1.2.2\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2021-05-21 18:11:46+00:00\n"
"POT-Creation-Date: 2023-09-16 14:52:26+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"PO-Revision-Date: 2021-MO-DA HO:MI+ZONE\n"
"PO-Revision-Date: 2023-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <EMAIL@ADDRESS>\n"
"X-Generator: grunt-wp-i18n 1.0.3\n"
Expand All @@ -25,19 +25,15 @@ msgid ""
"slips plugin%s to be installed & activated!"
msgstr ""

#: dokan-invoice.php:199
msgid "Download invoice (PDF)"
msgstr ""

#: dokan-invoice.php:234 dokan-invoice.php:242 dokan-invoice.php:276
#: dokan-invoice.php:241 dokan-invoice.php:249 dokan-invoice.php:283
msgid "store_info"
msgstr ""

#: dokan-invoice.php:236 dokan-invoice.php:244
#: dokan-invoice.php:243 dokan-invoice.php:251
msgid "Vendor:"
msgstr ""

#: dokan-invoice.php:272
#: dokan-invoice.php:279
msgid "From vendors:"
msgstr ""

Expand Down
Loading

0 comments on commit 50f9238

Please sign in to comment.