• Resolved crosscriss

    (@crosscriss)


    Pozdrav,

    Sve je bilo radilo normalno, no odjednom su narudzbe prestale slati u Solo, same od sebe.
    Nije mi istekla licenca bila, niti sam ista mijenjao bio, osim sto sam updateao WP i WC.

    U settingsima sam testirao radi li povezanost sa mojim Solo racunom, i radi jer je povukao sa API-a moje racune na Solou.

    Ne znam od kud da krenem, nisam imao upaljen debug, pa nemam neki log, a ako krenem stavljat random narudzbe, necu ih moc maknut iz Soloa

Viewing 15 replies - 16 through 30 (of 31 total)
  • Thread Starter crosscriss

    (@crosscriss)

    Da, evo upravo sam ju instalirao, pa isao onda testirat.
    Stavio sam WP Crontrol, i jos neki cron manager plugin, cisto da imam 2 razlicita prikaza cron eventsa, i ni na jednom nema za solo cron event.

    Jel bi i on trebao ovako nekako izgledat?
    “action_scheduler_run_queue, pa onda next run datum i vrijeme, neki Action, i recurrence”

    EDIT: Mogu li ja mozda nekako rucno napravit novi cron event preko crontrola ili cron managera?

    • This reply was modified 10 months, 1 week ago by crosscriss.
    Plugin Author Denis ?oljom

    (@dingo_d)

    Jedan cron event se zove: makeApiCall, drugi se zove sendCustomerEmail.

    Kada vam se izvrsava upit prema solo servisu? Na checkout ili na promijenu statusa u completed?

    Thread Starter crosscriss

    (@crosscriss)

    Stavio sam na promijenu statusa u completed.
    Nikako ne mogu skuzit sto ga je strgalo jer ja sam jedini dev na webu, i nisam nista mijenjao osim updateao redovno pluginove, dodao sam bio automatewoo jedino, ali kazem, izbrisao sam ga. Sad sam probao ponovno reinstalirat solo plugin, i dalje se ne triggera action.
    Kao da se nije ni registrirao uopce ovaj:
    add_action(‘woocommerce_order_status_completed’, [$this, ‘sendApiRequestOnOrderCompleted’], 30, 1);

    Plugin Author Denis ?oljom

    (@dingo_d)

    Kada stavite error_log(print_r('REGISTERED!', true)); unutar register metode u MakeApiRequest klasi, i pogledate logove, da li vidite taj string? Jer ako da, onda se registriraju ti hookovi i sve radi, ako ne, onda je negdje problem nastao.

    Thread Starter crosscriss

    (@crosscriss)

    Jel to sprema log u debug.log file ili neki drugi?
    Idem odmah probat pa da znam gdje trazit.

    EDIT: Znam gdje gledat error_log.
    Ne znam samo jel bi se register trebao triggerat na pocetku odmah, cim saveam file, ili ako dode do pokretanja tog hooka.

    • This reply was modified 10 months, 1 week ago by crosscriss.
    Plugin Author Denis ?oljom

    (@dingo_d)

    Register bi se trebao okinuti na pocetku requesta. Znaci bilo koji reload fronta, admina i slicno bi ga trebao okinuti.

    Thread Starter crosscriss

    (@crosscriss)

    Evo ga:

    17-Jan-2024 13:09:59 UTC] REGISTERED!
    [17-Jan-2024 13:10:01 UTC] REGISTERED!
    [17-Jan-2024 13:10:01 UTC] REGISTERED!
    [17-Jan-2024 13:10:16 UTC] REGISTERED!
    [17-Jan-2024 13:10:26 UTC] REGISTERED!
    [17-Jan-2024 13:10:26 UTC] REGISTERED!

    Plugin Author Denis ?oljom

    (@dingo_d)

    Ok, znaci da plugin ok registrira hookove. Iduci korak je da se error log stavi u jedan od dva callbacka – u vasem slucaju unutar sendApiRequestOnOrderCompleted metode.

    On bi se trebao okinuti kada se status narudzbe promijeni u completed.

    Thread Starter crosscriss

    (@crosscriss)

    Stavio sam 2 error loga.

    1. sam stavio odmah nakon definije metode:

    public function sendApiRequestOnOrderCompleted(int $orderId): void
    	{
    		error_log(print_r('FUNCTION COMPLETED AND REGISTERED!', true));
    ......

    2. sam stavio nakon if === ‘completed’

    if ($orderStatus === 'completed') {
    			error_log(print_r('IF COMPLETED AND REGISTERED!', true));

    1. se pojavio u logu, drugi nije.

    [17-Jan-2024 13:24:11 UTC] FUNCTION COMPLETED AND REGISTERED!
    Plugin Author Denis ?oljom

    (@dingo_d)

    Koji je $orderStatus?

    Thread Starter crosscriss

    (@crosscriss)

    [17-Jan-2024 14:07:48 UTC] processing

    Tu sam ga stavio:

    // Execute only if status is changed to completed!
    		$orderData = $order->get_data();
    		$orderStatus = $orderData['status'];
    
    		error_log(print_r($orderStatus, true));

    Cudno mi je da je processing, kad sam kliknuo na narudzbu i stavio na Zavrseno

    EDIT: Samo da napomenem, iz “U obradi” (processing) sam ju prebacio u Zavrseno. pa mi je cudno da je orderstatus stari, a ne novi u koji sam ju prebacio

    • This reply was modified 10 months, 1 week ago by crosscriss.
    • This reply was modified 10 months, 1 week ago by crosscriss.
    Plugin Author Denis ?oljom

    (@dingo_d)

    Da, trebao bi biti novi order pogotovo jer se okine na hook koji sluzi da se okine kad se prebaci status u completed. Morat cu istraziti to malo da vidim da li mi se desava slicno.

    Thread Starter crosscriss

    (@crosscriss)

    Moguce da se dogadja da se hook okine i onda metoda izvrti prije nego server izvrsi promjenu u completed.
    Ne znam sad tocno redoslijed, ali kad ja kliknem na Dovrseno, pokrene se nekoliko async stvari, i onda ova za solo api vjerojatno zavrsi prije nego se izvrsi promjena order statusa u completed

    • This reply was modified 10 months, 1 week ago by crosscriss.
    Thread Starter crosscriss

    (@crosscriss)

    Nasao sa rijesenje koje meni funckionira.
    Napravio sam ove promjene u kodu:

    {
    add_action('woocommerce_email_order_details', [$this, 'sendApiRequestOnCheckout'], 15, 4);
    add_action('woocommerce_order_status_changed', [$this, 'sendApiRequestOnOrderCompleted'], 30, 3);
    }

    onaj hook sam zamjenio sa ‘woocommerce_order_status_changed’ jer taj hook ima $old_status i $new_status parametre. Dok woocommerce_order_status_completed se triggera odmah, kad se napravi zahtjev za promjenom statusa u completed, ali se moze dogoditi da se sam order jos nije izmjenio (njegov status u completed), sto je kod mene problem bio.

    I onda sam if provjeru samo prilagodio:

    if (!is_admin() || $old_status === $new_status || $new_status !== 'completed') {
        return;
    }

    i tu:

    if ($new_status === 'completed') {...}

    Definicija metode izgleda ovako sada:

    public function sendApiRequestOnOrderCompleted(int $orderId, $old_status, $new_status): void

    Sada sve radi normalno

    • This reply was modified 10 months, 1 week ago by crosscriss.
    • This reply was modified 10 months, 1 week ago by crosscriss.
    • This reply was modified 10 months, 1 week ago by crosscriss. Reason: code looked ugly
    Plugin Author Denis ?oljom

    (@dingo_d)

    Nisam jos provjerio, ali cu pogledati i testirat pa mogu updateati kod na pluginu. Hvala!

Viewing 15 replies - 16 through 30 (of 31 total)
  • The topic ‘Narudzbe se vise ne salju u Solo’ is closed to new replies.