Dobrý deň,
používali sme staršiu verziu pluginu 1.4.2. (Už prebehla aktualizácia)
Implementujete vo svojom eshope niektorý z filtrov dostupných v plugine pre modifikáciu dáť alebo vystavovanie faktúr?
Funkcia vystavenia dobropisu a ešte funkcia označenia že faktúra nebude uhradená:
add_action('woocommerce_order_status_cancelled', 'set_invoice_will_not_be_paid', 10, 1);
function set_invoice_will_not_be_paid($order_id) {
$order = wc_get_order($order_id);
$invoice_id = get_post_meta($order_id, 'wc_sf_internal_regular_id', true);
if ($invoice_id) {
$api_url_base = 'https://moja.superfaktura.sk';
$auth_email = 'xxxx'; // Email, ktorý použiješ
$auth_api_key = 'xxxx';
$auth_company_id = 'xxxx';
$encoded_email = urlencode($auth_email); // URL kódovanie pre email
$headers = array(
'Authorization' => "SFAPI email=$encoded_email&apikey=$auth_api_key&company_id=$auth_company_id",
'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8'
);
$url = $api_url_base . "/invoices/will_not_be_paid/" . $invoice_id;
$response = wp_remote_get($url, array('headers' => $headers));
if (is_wp_error($response)) {
$error_message = $response->get_error_message();
// Môžete pridať logovanie alebo ďalšie spracovanie chyby
error_log("Error marking invoice $invoice_id as 'will not be paid': $error_message");
} else {
$status_code = wp_remote_retrieve_response_code($response);
if ($status_code == 200) {
error_log("Invoice $invoice_id marked as 'will not be paid'.");
} else {
$error_message = wp_remote_retrieve_body($response);
error_log("Failed to mark invoice $invoice_id as 'will not be paid': $error_message");
}
}
} else {
error_log("Invoice ID not found for order $order_id.");
}
}
function custom_generate_invoicedobropis( $generate_invoice, $order, $type, $payment_method ) {
if ( 'cancel' === $type && 'cancelled' === $order->get_status() ) {
$previous_status = $order->get_meta( 'previous_status_before_cancelled' );
// Ak to išlo z "on-hold" na "cancelled", tak nechceme generovať dobropis
if ( 'on-hold' === $previous_status ) {
return false;
}
return true;
}
return $generate_invoice;
}
add_filter( 'sf_generate_invoice', 'custom_generate_invoicedobropis', 10, 4 );
add_filter( 'woocommerce_email_attachments', 'modify_sf_invoice_attachment_email', 20, 3 );
function modify_sf_invoice_attachment_email( $attachments, $email_id, $order ) {
$wc_sf_invoice_cancel = get_post_meta( $order->get_id(), 'wc_sf_invoice_cancel', true );
if ( ! empty( $wc_sf_invoice_cancel ) ) {
$attachments[] = $wc_sf_invoice_cancel;
}
return $attachments;
}
Máte zapnutú experimentálnu funkciu, ktorá zabraňuje duplicite dokumentov spôsobených callbackmi niektorých platobných brán? Skúsili ste ju vypnúť? Pri akej platobnej metóde sa táto chyba prejavuje? – Áno je zapnutá. Môžeme skúsiť vypnúť. Ide o rôzne platobné metódy ako BACS, Stripe či dobierku.
Skúsili ste vypnúť experimentálnu funkciu pre opakovanie neúspešných API volaní, či sa chyba prejaví aj v tom prípade? – Môžeme skúsiť vypnúť.