quaderno / quaderno-edd Goto Github PK
View Code? Open in Web Editor NEWEasy Digital Downloads Tax Extension by Quaderno
Home Page: https://quaderno.io/integrations/easy-digital-downloads/
Easy Digital Downloads Tax Extension by Quaderno
Home Page: https://quaderno.io/integrations/easy-digital-downloads/
It appears that line 57 of edd-quardeno.js should reference #edd_checkout_cart_form
, not #edd_checkout_cart
. The response fromedd_checkout_cart()
(which is called via the AJAX function edd_ajax_recalculate_taxes()
) includes the #edd_checkout_cart_form
div in the HTML response itself, so you end up nesting the div over and over again unintentionally.
Can Quaderno, while generating the invoice, update the subscription payment taxes (product tax and total tax)?
This would help to keep the data across the payments and invoices unified. Now ie. when tax ID is not valid the invoice can have different data than saved within the payment (VAT exempt).
The problem is that there's an inconsistency between the Quaderno invoice and EDD payment details.
Ie. someone purchases something, the Quaderno tax is set to 0 and invoice is generated without it while in payment details you can still see the tax, ie. 23%.
Maybe it's because I have the store set up in a way the total price is always the same (tax included).
To save the tax info I can get from Quaderno I created a simple snippet:
function edd_quaderno_tax_rewrite( $payment_id ) {
$payment = new EDD_Payment( $payment_id );
if ( $payment->total == 0 || ! function_exists( 'edd_quaderno_tax' ) ) {
return;
}
$metadata = $payment->get_meta();
$vat_number = isset( $metadata['vat_number'] ) ? $metadata['vat_number'] : '';
$tax = edd_quaderno_tax( $payment->address['country'], $payment->address['zip'], $vat_number );
$tax_rate = $tax->rate / 100;
$total = $payment->total;
$net = $total / ( 1 + $tax_rate );
$tax = $total - $net;
// Update each product tax and total.
foreach ( $payment->cart_details as $item_index => $item_details ) {
$item_total = $item_details['item_price'];
$item_net = $item_total / ( 1 + $tax_rate );
$item_tax = $item_total - $item_net;
$payment->modify_cart_item( $item_index, array(
'item_price' => $item_net,
'subtotal' => $item_net * $item_details['quantity'],
'tax' => $item_tax,
) );
}
// Update tax rate, tax total is calculated automatically when updating items.
$payment->tax_rate = $tax_rate;
$payment->subtotal = $net;
$payment->total = $total;
$payment->save();
}
add_action( 'edd_complete_purchase', 'edd_quaderno_tax_rewrite', 100 );
add_action( 'edd_recurring_record_payment', 'edd_quaderno_tax_rewrite', 100 );
Note: this is untested and probably needs more logic like tax included/excluded and discounts handling.
If you checkout as a customer with a saved Billing State when EDD Quaderno is active, the saved state does not show up in the Billing State field. This happens because Quaderno triggers the change event on the #billing_country dropdown when the page loads, thus causing EDD to regenerate and replace the Billing State field.
It would be very helpful if the Quaderno invoice URL was available in the EDD Purchase Receipt emails as tag (e.g. quaderno_invoice_url
) so we can link it directly in the receipts customers receive.
Here's the code example from EDD how they easily add their stripe related tag:
/**
* Register the statement_descriptor email tag.
*
* @since 2.6
* @return void
*/
function edd_stripe_register_email_tags() {
$statement_descriptor = edds_get_statement_descriptor();
if ( ! empty( $statement_descriptor ) ) {
edd_add_email_tag(
'stripe_statement_descriptor',
__( 'Outputs a line stating what charges will appear as on customer\'s credit card statements.', 'edds' ),
'edd_stripe_statement_descriptor_template_tag',
__( 'Statement Descriptor', 'edds' )
);
}
}
add_action( 'edd_add_email_tags', 'edd_stripe_register_email_tags' );
/**
* Swap the {statement_descriptor} email tag with the string from the option
*
* @since 2.6
* @param $payment_id
*
* @return mixed
*/
function edd_stripe_statement_descriptor_template_tag( $payment_id ) {
$payment = new EDD_Payment( $payment_id );
if ( 'stripe' !== $payment->gateway ) {
return '';
}
$statement_descriptor = edds_get_statement_descriptor();
if ( empty( $statement_descriptor ) ) {
return '';
}
// If you want to filter this, use the %s to define where you want the actual statement descriptor to show in your message.
$email_tag_output = __( apply_filters( 'edd_stripe_statement_descriptor_email_tag', 'Charges will appear on your card statement as %s' ), 'edds' );
return sprintf( $email_tag_output, $statement_descriptor );
}
We received the following PHP warnings on a test site.
Occurred when my colleague created an invoice + made a refund.
You should maybe add some checks before working with the variables/properties etc.
[06-Nov-2023 14:54:57 UTC] PHP Warning: Attempt to read property "ip" on bool in /sites/dev.com/files/wp-content/plugins/edd-quaderno/includes/invoices.php on line 241
[06-Nov-2023 14:56:40 UTC] PHP Warning: Undefined variable $tax in /sites/dev.com/files/wp-content/plugins/edd-quaderno/includes/credits.php on line 49
[06-Nov-2023 14:56:40 UTC] PHP Warning: Attempt to read property "notes" on null in /sites/dev.com/files/wp-content/plugins/edd-quaderno/includes/credits.php on line 49
[06-Nov-2023 14:56:40 UTC] PHP Warning: Undefined variable $tax in /sites/dev.com/files/wp-content/plugins/edd-quaderno/includes/credits.php on line 49
As a heads-up, the EDD team is working on plugin v3.0 and there's already first beta published.
I think this affects the Quaderno plugin as it stores custom meta within the Payment.
An error of type E_ERROR was caused in line 85 of the file /sites/bracketspace.com/files/web/app/plugins/edd-quaderno/includes/taxes.php.
Error message: Uncaught Error: Call to undefined function edd_get_customer_by() in /sites/example.com/files/web/app/plugins/edd-quaderno/includes/taxes.php:85
I suppose that function has been introduced in EDD 3.0, we're using EDD 2.11.7 for the sake of another compatibility.
When you create the credit here: https://github.com/quaderno/quaderno-edd/blob/master/includes/credits.php#L46 it would be awesome to include the related document (initial invoice).
I believe this should be the document_id
key which sits in the payment meta _quaderno_invoice_id
Hey @polimorfico,
while working on something, my colleague experienced the following situation:
Maybe worth checking out if you can reproduce and perhaps optimize the code, if needed?
This only happens if a user goes through EDD checkout with a saved address. The EDD Stripe plugin hides all billing address fields, including edd_tax_id_wrap, on page load. The EDD Quaderno JS interferes with this as it fires toggle_tax_id_fields() on the 'edd_gateway_loaded' JS event which causes the Tax ID field to be displayed when all other billing address fields are hidden
Hi @polimorfico , i am florian's colleague (@flowdee)
in some cases on our web sites (different server and different domain) the invoices are not generated. If you try to create them manually in EDD, the following critical error occurs:
`Fatal error: Uncaught Error: Too few arguments to function edd_quaderno_get_order_meta(), 1 passed in /sites/files/wp-content/plugins/edd-quaderno/includes/invoices.php on line 241 and exactly 2 expected
in /sites/files/wp-content/plugins/edd-quaderno/includes/order_details.php on line 54
Call stack:
edd_quaderno_get_order_meta()
wp-content/plugins/edd-quaderno/includes/invoices.php:241
edd_quaderno_process_recurring_payment()
wp-content/plugins/edd-quaderno/includes/invoices.php:264
edd_quaderno_resend_invoice()
wp-includes/class-wp-hook.php:308
WP_Hook::apply_filters()
wp-includes/class-wp-hook.php:332
WP_Hook::do_action()
wp-includes/plugin.php:517
do_action()
wp-content/plugins/easy-digital-downloads-pro/includes/admin/admin-actions.php:28
edd_process_actions()
wp-includes/class-wp-hook.php:308
WP_Hook::apply_filters()
wp-includes/class-wp-hook.php:332
WP_Hook::do_action()
wp-includes/plugin.php:517
do_action()
wp-admin/admin.php:175
require_once()
wp-admin/edit.php:10`
Do you have any idea?
Thanks, best,
Mirko
We regularly experience the issue that customers who got charged for renewal orders (subscriptions) automatically, receive invoices without VAT details.
The problem: When they purchased in the past, they forgot to add their details in the checkout.
Even when we update the details directly via Quaderno (and create credit notes), next year, when subscription renewal hits, the invoices are created again without VAT details. I think it's because the data is missing in EDD?
It would be great if customers (and we EDD admins) could update VAT details (number and company name) via EDD.
Shortcode: [edd_profile_editor]
action: edd_process_refund_form
data: edd_process_refund=ff58f48ada&_wp_http_referer=%2Fwp-admin%2Fadmin-ajax.php&refund_order_item%5B%5D=46312&refund_order_item%5B46312%5D%5Bquantity%5D=1&refund_order_item%5B46312%5D%5Bsubtotal%5D=399.00&edd-paypal-refund=1&edd_recurring_cancel_subscription%5B10419%5D=10419
order_id: 258516
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.