Forum Replies Created

Viewing 15 replies - 31 through 45 (of 77 total)
  • Thread Starter User

    (@lostguybrazil)

    Hi @crossi72,

    Thank you for the quick response! I wanted to provide a bit more information: three of the websites mentioned are hosted on a VPS Debian server. Out of these, two websites are experiencing the issue, while one is not. This leads me to believe that the problem might not be related to hosting limitations, as one of the sites is functioning correctly.

    Thanks again for your help!

    Thread Starter User

    (@lostguybrazil)

    Hi @crossi72, thank you for checking the plugins and replicating my setup.

    For the WordPress Debug file, I don’t see anything related to this issue.

    For the server log file, I have noticed that this entry is added to the log every time I try to open the the Media Library page (Media > Library) (/wp-admin/upload.php) (the number *314044 changes slightly on every entry): “nginx error: 1588306#0: *314044 upstream sent too big header while reading response header from upstream”.

    Maybe it helps!

    Kind regards

    Thread Starter User

    (@lostguybrazil)

    Thank you for your quick response! I currently have 4 websites running the latest version of “Phoenix Media Rename” (v3.12.6). On 2 of these websites, I am encountering the issue described in the original post (OP).

    Here are the plugins installed on one of the problematic websites:
    AAA Option Optimizer – 1.2.1
    Admin and Site Enhancements (ASE) – 7.5.1
    Advanced Database Cleaner PRO – 3.2.10
    Brazilian Market on WooCommerce – 4.0.2
    Cloudflare – 4.12.8
    Complianz | GDPR/CCPA Cookie Consent – 7.1.4
    Connect Polylang for Elementor – 2.4.5
    CTX Feed – 6.5.31
    Easy Auto SKU Generator for WooCommerce – 1.2.0
    Edit Custom Fields – 0.1.10
    Elementor – 3.25.4
    Embed Google Fonts – 3.1.1
    Google Analytics for WooCommerce – 2.1.7
    Matomo Analytics – Ethical Stats. Powerful Insights. – 5.1.5
    Melhor Envio – 2.15.9
    Mercado Pago – 7.8.2
    PhastPress – 3.6
    Polylang – 3.6.5
    Polylang for WooCommerce – 2.1
    Polylang Slug – 0.2.3
    Query Monitor – 3.16.4
    Redis Object Cache – 2.5.4
    Secure Custom Fields – 6.3.10.2
    Site Kit by Google – 1.139.0
    Smash Balloon Instagram Feed – 6.6.0
    WC Variations Radio Buttons – 2.1.0
    WooCommerce – 9.3.3
    Wordfence Security – 8.0.0
    WP-Optimize – Clean, Compress, Cache – 3.7.0
    WPCode Lite – 2.2.3
    WP Consent API – 1.0.7
    WP Console – 2.4.1
    WP Crontrol – 1.17.0
    XML Sitemap Generator for Google – 4.1.21

    And here are the plugins found on one of the problematic websites that are not present on the non-problematic website:
    Brazilian Market on WooCommerce – 4.0.2
    CTX Feed – 6.5.31
    Easy Auto SKU Generator for WooCommerce – 1.2.0
    Edit Custom Fields – 0.1.10
    Google Analytics for WooCommerce – 2.1.7
    Melhor Envio – 2.15.9
    Mercado Pago – 7.8.2
    Polylang for WooCommerce – 2.1
    Secure Custom Fields – 6.3.10.2
    Smash Balloon Instagram Feed – 6.6.0
    WC Variations Radio Buttons – 2.1.0
    WooCommerce – 9.3.3

    I have already tried deactivating these plugins, but the issue persists:
    CTX Feed – 6.5.31
    Easy Auto SKU Generator for WooCommerce – 1.2.0
    Edit Custom Fields – 0.1.10
    Google Analytics for WooCommerce – 2.1.7
    Polylang for WooCommerce – 2.1
    Secure Custom Fields – 6.3.10.2
    Smash Balloon Instagram Feed – 6.6.0
    WC Variations Radio Buttons – 2.1.0

    Additionally, I have attempted the following steps:
    – Clearing the browser cache.
    – Reducing the “Number of items per page” settings in the Media Library to 10 before enabling the “Phoenix Media Rename” plugin.

    It may be worth noting that both websites experiencing the issue have over 100 media files, while the websites where the plugin works as expected have a low number of media uploads. This could be only a coincidence.

    Thanks again!

    Thread Starter User

    (@lostguybrazil)

    Hi @antoiub,

    I have just opened a issue ticket through https://complianz.io/support/

    Thanks!

    Kind regards

    Thread Starter User

    (@lostguybrazil)

    Thanks!

    Thread Starter User

    (@lostguybrazil)

    Hi,

    I have noticed that the updated solves the problem in the check-out process – but not in the “My Account” > “Addresses” > Billing address/Shipping address page.

    Could you update the logic there too?

    Thanks!

    Kind regards

    Thread Starter User

    (@lostguybrazil)

    Thanks for the quick support!

    Thread Starter User

    (@lostguybrazil)

    Hi Dennis,

    Thank you for your answer. I tried to reset the global variable $sab_document_types, but it got even worse, the whole email is sent in English (instead of the language ordered by the customer).

    <?php

    // WooCommerce - Order email notifications language set based on order using Polylang
    // Last update: 2024-09-24

    if (class_exists('WooCommerce') && WC() && class_exists('Polylang')) {

    class WC_Email_Locale_Handler
    {
    public function __construct()
    {
    // Hook into the email header to switch locale before email content
    add_action($hook_name = 'woocommerce_email_header', $callback = [$this, 'set_email_locale_based_on_order'], $priority = 10, $accepted_args = 2);
    add_action($hook_name = 'woocommerce_email_before_order_table', $callback = [$this, 'set_email_locale_based_on_order'], $priority = 10, $accepted_args = 2);

    // Hook into the email footer to restore the original locale after email content
    add_action($hook_name = 'woocommerce_email_footer', $callback = [$this, 'restore_email_locale'], $priority = 10, $accepted_args = 1);

    // Hook into resending emails to handle locale switching
    add_action($hook_name = 'woocommerce_before_resend_order_emails', $callback = [$this, 'set_locale_on_woocommerce_before_resend_order_emails'], $priority = 10, $accepted_args = 1);

    // Hook into email recipient filter to switch locale before generating the subject
    add_filter($hook_name = 'woocommerce_email_recipient_new_order', $callback = [$this, 'set_locale_on_woocommerce_email_recipient_new_order'], $priority = 10, $accepted_args = 2);
    }

    public function set_email_locale_based_on_order($email_heading, $email)
    {
    if (isset($email->object)) {
    // Get the language locale of the order
    $order_locale = $this->get_locale_from_object($email->object);

    if ($order_locale) {
    // Switch to the order's locale
    switch_to_locale($order_locale);
    // Reset the global document types
    if (function_exists('sab_register_document_type')) {
    $this->reset_sab_document_types();
    }
    }
    }
    }

    public function restore_email_locale()
    {
    restore_previous_locale();
    }

    public function set_locale_on_woocommerce_before_resend_order_emails($order)
    {
    if ($order) {
    // Get the language locale of the order
    $order_locale = $this->get_locale_from_object($order);

    if ($order_locale) {
    // Switch to the order's locale
    switch_to_locale($order_locale);
    // Reset the global document types
    if (function_exists('sab_register_document_type')) {
    $this->reset_sab_document_types();
    }
    }
    }
    }

    public function set_locale_on_woocommerce_email_recipient_new_order($to, $order)
    {
    // Get the order locale
    $order_locale = $this->get_locale_from_object($order);

    if ($order_locale) {
    // Switch to the order's locale before generating the subject
    switch_to_locale($order_locale);
    }

    return $to;
    }

    private function map_language_to_locale($language_slug)
    {
    // Define a mapping of language slugs to locale codes
    $mapping = array(
    'de' => 'de_DE',
    'en' => 'en_US',
    'pt' => 'pt_BR',
    );

    return isset($mapping[$language_slug]) ? $mapping[$language_slug] : false;
    }

    private function get_locale_from_object($object)
    {
    $order = null;

    // Check if the object is a WC_Order or if the object is a Shipment/Invoice from "Germanized for WooCommerce" plugin
    if (is_a($object, 'WC_Order')) {
    $order = $object;
    } elseif (is_a($object, 'Vendidero\Germanized\Shipments\Shipment') || is_a($object, 'Vendidero\StoreaBill\Invoice\Invoice')) {
    $order = $object->get_order();
    }

    if ($order && function_exists('pll_get_post_language')) {
    // Get the language slug of the order
    $order_language = pll_get_post_language($order->get_id(), 'slug');

    // Map the language slug to a locale code
    return $this->map_language_to_locale($order_language);
    }

    return null;
    }

    private function reset_sab_document_types()
    {
    global $sab_document_types; // Import the global variable

    // Reset the global document types to force reloading in the current language
    if (isset($sab_document_types)) {
    $sab_document_types = array(); // Clear the existing types
    Package::register_document_types(); // Re-register document types
    }
    }
    }

    // Initialize the handler class
    new WC_Email_Locale_Handler();
    }

    I think I will give up. It would be nice to have official support to Polylang in the future. Perhaps a simple edit in the get_order_language( $order ) function stored in the woocommerce-germanized-pro/packages/storeabill/src/Compatibility/WPML.php file would solve this problem, like:

    protected static function get_order_language( $order ) {
    $order = is_numeric( $order ) ? wc_get_order( $order ) : $order;
    $lang = '';

    if ( $order ) {
    if ( function_exists('icl_object_id') ) {
    $lang = $order->get_meta( 'wpml_language' ); // WPML
    } else if ( function_exists('pll_get_post_language') ) {
    $lang = pll_get_post_language($order->get_id(), 'slug'); // Polylang
    $lang = map_language_to_locale($lang);
    }
    }

    return $lang;
    }

    Kind regards

    Thread Starter User

    (@lostguybrazil)

    Not sure if you got a notification, thus replying to this topic: @vendidero

    Kind regards

    Thread Starter User

    (@lostguybrazil)

    Hi @antoiub, are there any news regarding this issue? Almost two months have passed since I first reported it.

    Thanks and kind regards

    Thread Starter User

    (@lostguybrazil)

    Hi Dennis,

    Unfortunately I have noted that my latest code (posted in Stack Overflow) and the original code (posted in this thread) do not translate, for the invoice emails, the subject line (“Invoice 2024 xxx from website”) and the word “Invoice” in the email content header and the content (“Hi first name last name, Invoice 2024 xxx…”).

    Probably I need to trigger add_action before hooks not yet added to my code. I did not find where. Could you please support me?
    Maybe also needed for shipping information, but I was not able to test the need for it.

    Thanks!

    User

    (@lostguybrazil)

    I had to make some changes to work also with the email subject and email content heading. For reference, the updated code can be found here: https://stackoverflow.com/a/79002683/9195104

    Thread Starter User

    (@lostguybrazil)

    I had to make some changes to work also with the email subject and email content heading. For reference, the updated code can be found here: https://stackoverflow.com/a/79002683/9195104

    User

    (@lostguybrazil)

    Prezados,

    Estou procurando a mesma funcionalidade no Checkout Transparente.

    Não encontrei tal opção: “Vai em Configurações > Mercado Pago Checkout Pro > Configurações avançadas
    Lá vai ter Pagamento recusado, Pagamento com sucesso e Pagamento pendente”

    Tentei por código PHP mas não funcionou. Poderiam me auxiliar?

    <?php
    // Add the AJAX handler for checking order status
    add_action($hook_name = 'wp_ajax_check_order_status', $callback = 'check_order_status', $priority = 10, $accepted_args = 1);
    add_action($hook_name = 'wp_ajax_nopriv_check_order_status', $callback = 'check_order_status', $priority = 10, $accepted_args = 1);

    function check_order_status()
    {
    // Get the order ID from the AJAX request
    $order_id = isset($_POST['order_id']) ? absint($_POST['order_id']) : 0;

    // Load the order
    $order = wc_get_order($order_id);

    if ($order) {
    // Return the current status of the order
    wp_send_json_success(array( 'status' => $order->get_status() ));
    } else {
    wp_send_json_error('Order not found');
    }
    }

    // Inject JavaScript on the PIX payment confirmation page (order-received)
    add_action($hook_name = 'wp_enqueue_scripts', $callback = 'enqueue_pix_status_script', $priority = 10, $accepted_args = 1);
    function enqueue_pix_status_script()
    {
    // Check if we are on the order received page
    if (is_order_received_page() && isset($_GET['key'])) {
    $order_id = wc_get_order_id_by_order_key($_GET['key']);
    $order = wc_get_order($order_id);

    // Check if the payment method is Mercado Pago PIX
    if ($order && $order->get_payment_method() == 'woo-mercado-pago-pix') {
    // Enqueue the JavaScript code
    ?>
    <script type="text/javascript">
    jQuery(document).ready(function($) {
    var order_id = <?php echo $order_id; ?>;

    // Polling function to check order status
    function checkOrderStatus() {
    $.ajax({
    url: '<?php echo admin_url('admin-ajax.php'); ?>',
    type: 'POST',
    data: {
    action: 'check_order_status',
    order_id: order_id
    },
    success: function(response) {
    if (response.success && response.data.status === 'processing') {
    // Payment has been completed, redirect to thank you page or show a success message
    window.location.href = '<?php echo wc_get_checkout_url(); ?>';
    }
    },
    error: function() {
    console.log('Error checking order status');
    }
    });
    }

    // Set an interval (in milliseconds) to check the order status
    setInterval(checkOrderStatus, 5000);
    });
    </script>
    <?php
    }
    }
    }
    Thread Starter User

    (@lostguybrazil)

    Hi Dennis, thank you for your answer. I was able to retrieve it – here’s the code for future reference.

    Thanks!

    $order_id = 1234;
    $order = wc_get_order($order_id);
    $invoice = wc_gzdp_get_order_last_invoice($order);

    if ($invoice) {
    // Invoice exists
    echo "Invoice Created: True<br>";

    // Get the invoice date
    $invoice_date = $invoice->get_date_created();
    echo "Invoice Date: " . $invoice_date->date('Y-m-d H:i:s') . "<br>";

    // Get the invoice number
    $invoice_number = $invoice->get_formatted_number();
    echo "Invoice Number: " . $invoice_number . "<br>";
    } else {
    // No invoice found
    echo "Invoice Created: False<br>";
    }
Viewing 15 replies - 31 through 45 (of 77 total)