Beiträge von Azrael_0815
-
-
Okay, entferne das mit dem do_action wieder. Wir führen einen neuen Status ein:
Nach
$order = new WC_Order( $order_id ); im Plugin fügst Du ein:
PHP
Alles anzeigenfunction hardcopy_order_status() { register_post_status( 'hardcopy', array( 'label' => 'Hardcopy', 'public' => true, 'exclude_from_search' => false, 'show_in_admin_all_list' => true, 'show_in_admin_status_list' => true, 'label_count' => _n_noop( 'Hardcopy <span class="count">(%s)</span>', 'Hardcopy <span class="count">(%s)</span>' ) ) ); } add_action( 'init', 'hardcopy_order_status' ); function add_hardcopy_order_status( $order_statuses ) { $new_order_statuses = array(); // add new order status after processing foreach ( $order_statuses as $key => $status ) { $new_order_statuses[ $key ] = $status; if ( 'wc-processing' === $key ) { $new_order_statuses['hardcopy'] = 'Hardcopy'; } } return $new_order_statuses; } add_filter( 'wc_order_statuses', 'add_order_hardcopy_status' );Gibt es jetzt den neuen Status "Hardcopy" im Backend?
-
-
Mach mal folgendes:
Entferne den Hook processing aus der woohelper.php.
add_action('woocommerce_order_status_processing', array(&$this, 'process_order_tickets'), 10, 1);
weg.
Und dann
do_action('woocommerce_order_status_completed', array(&$this, 'process_order_tickets'), 10, 1);
hinter das else { im Plugin.
Damit führt er die Aktion aus, ändert aber nix am Status. Es sei denn, die Funktion ändert da noch was.
-
-
-
-
-
-
-
-
-
-
Probier mal das Plugin.
Das müsste die Tickets erstellen, auch wenn kein Completed.
[COLOR=#000000] [COLOR=#0000BB]<?php
[/COLOR][COLOR=#FF8000]/*
Plugin Name: Update Status, if not Hardcopy-Ticket*/
/** * bezahlte Bestellungen automatisch abschliessen
*/
[/COLOR][COLOR=#0000BB]add_action[/COLOR][COLOR=#007700]( [/COLOR][COLOR=#DD0000]'woocommerce_thankyou'[/COLOR][COLOR=#007700], [/COLOR][COLOR=#DD0000]'auto_complete_paid_order'[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000BB]10[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000BB]1 [/COLOR][COLOR=#007700]);
function [/COLOR][COLOR=#0000BB]auto_complete_paid_order[/COLOR][COLOR=#007700]( [/COLOR][COLOR=#0000BB]$order_id [/COLOR][COLOR=#007700]) {
if ( ! [/COLOR][COLOR=#0000BB]$order_id [/COLOR][COLOR=#007700]) {
return;
}
global [/COLOR][COLOR=#0000BB]$woocommerce[/COLOR][COLOR=#007700];
[/COLOR][COLOR=#0000BB]$order [/COLOR][COLOR=#007700]= new [/COLOR][COLOR=#0000BB]WC_Order[/COLOR][COLOR=#007700]( [/COLOR][COLOR=#0000BB]$order_id [/COLOR][COLOR=#007700]);
[/COLOR][COLOR=#FF8000]// kein Status Update fuer folgende Zahlungsarten
[/COLOR][COLOR=#007700]if ( ( [/COLOR][COLOR=#0000BB]get_post_meta[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]$order[/COLOR][COLOR=#007700]->[/COLOR][COLOR=#0000BB]id[/COLOR][COLOR=#007700], [/COLOR][COLOR=#DD0000]'_payment_method'[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000BB]true[/COLOR][COLOR=#007700]) == [/COLOR][COLOR=#DD0000]'bacs' [/COLOR][COLOR=#007700]) || ( [/COLOR][COLOR=#0000BB]get_post_meta[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]$order[/COLOR][COLOR=#007700]->[/COLOR][COLOR=#0000BB]id[/COLOR][COLOR=#007700], [/COLOR][COLOR=#DD0000]'_payment_method'[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000BB]true[/COLOR][COLOR=#007700]) == [/COLOR][COLOR=#DD0000]'cod' [/COLOR][COLOR=#007700]) || ( [/COLOR][COLOR=#0000BB]get_post_meta[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]$order[/COLOR][COLOR=#007700]->[/COLOR][COLOR=#0000BB]id[/COLOR][COLOR=#007700], [/COLOR][COLOR=#DD0000]'_payment_method'[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000BB]true[/COLOR][COLOR=#007700]) == [/COLOR][COLOR=#DD0000]'cheque' [/COLOR][COLOR=#007700]) ) {
return;
}
[/COLOR][COLOR=#FF8000]// "completed" fuer alle anderen Zahlungsarten
[/COLOR][COLOR=#007700]else {
[/COLOR][COLOR=#FF8000]//DMS
[/COLOR][COLOR=#0000BB]$noticketsend[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#DD0000]""[/COLOR][COLOR=#007700];
[/COLOR][COLOR=#0000BB]$the_order [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]wc_get_order[/COLOR][COLOR=#007700]( [/COLOR][COLOR=#0000BB]$order_id [/COLOR][COLOR=#007700]);
foreach( [/COLOR][COLOR=#0000BB]$the_order[/COLOR][COLOR=#007700]->[/COLOR][COLOR=#0000BB]get_items[/COLOR][COLOR=#007700]([/COLOR][COLOR=#DD0000]'fee'[/COLOR][COLOR=#007700]) as [/COLOR][COLOR=#0000BB]$item_id [/COLOR][COLOR=#007700]=> [/COLOR][COLOR=#0000BB]$item_fee [/COLOR][COLOR=#007700]){
[/COLOR][COLOR=#0000BB]$fee_name [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]$item_fee[/COLOR][COLOR=#007700]->[/COLOR][COLOR=#0000BB]get_name[/COLOR][COLOR=#007700]();
if ([/COLOR][COLOR=#0000BB]$fee_name[/COLOR][COLOR=#007700]==[/COLOR][COLOR=#DD0000]"Hardcopy-Ticket:"[/COLOR][COLOR=#007700]) {
[/COLOR][COLOR=#0000BB]$noticketsend[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#DD0000]"YES"[/COLOR][COLOR=#007700];
}
}
[/COLOR][COLOR=#FF8000]//DMS
//DMS
[/COLOR][COLOR=#007700]if (empty([/COLOR][COLOR=#0000BB]$noticketsend[/COLOR][COLOR=#007700])) {
[/COLOR][COLOR=#FF8000]//DMS
[/COLOR][COLOR=#0000BB]$order[/COLOR][COLOR=#007700]->[/COLOR][COLOR=#0000BB]update_status[/COLOR][COLOR=#007700]( [/COLOR][COLOR=#DD0000]'completed' [/COLOR][COLOR=#007700]);
[/COLOR][COLOR=#FF8000]//DMS
[/COLOR][COLOR=#007700]} else {
process_order_tickets($order_id);
}
[/COLOR][COLOR=#FF8000]//DMS
[/COLOR][COLOR=#007700]}
[/COLOR][COLOR=#FF8000]//DMS
[/COLOR][COLOR=#007700]}[/COLOR][COLOR=#0000BB]?>[/COLOR] [/COLOR]
-
Habe den Fehler glaube ich gefunden. Fooevents hat da einen Hook drin, der nur bei Completed anspringt.
PHPadd_action('woocommerce_order_status_completed', array(&$this, 'process_order_tickets'), 10, 1);Wenn Status=Completed, process_order_tickets.
Wenn also Status nicht Completed, werden die PDFs wohl nicht erstellt.
-
-
Probiere mal das:
PHP
Alles anzeigen//DMS if (!empty($noticketsend)) { //DMS $order->update_status( 'processing' ); //DMS } else { $order->update_status( 'completed' );} //DMS } //DMSAlso wenn Hardcopy-Ticket, setzt er die Order auf processing und sonst auf completed. Das ist eine Woocommerce - Funktion, dürfte also nix mit den PDFs zu tun haben.
-
-
Plugin, welches die Order auf Completed setzt, wenn kein Hardcopy-Ticket.
PHP
Alles anzeigen<?php /* Plugin Name: Update Status, if not Hardcopy-Ticket */ /** * bezahlte Bestellungen automatisch abschliessen */ add_action( 'woocommerce_thankyou', 'auto_complete_paid_order', 10, 1 ); function auto_complete_paid_order( $order_id ) { if ( ! $order_id ) { return; } global $woocommerce; $order = new WC_Order( $order_id ); // kein Status Update fuer folgende Zahlungsarten if ( ( get_post_meta($order->id, '_payment_method', true) == 'bacs' ) || ( get_post_meta($order->id, '_payment_method', true) == 'cod' ) || ( get_post_meta($order->id, '_payment_method', true) == 'cheque' ) ) { return; } // "completed" fuer alle anderen Zahlungsarten else { //DMS $noticketsend=""; $the_order = wc_get_order( $order_id ); foreach( $the_order->get_items('fee') as $item_id => $item_fee ){ $fee_name = $item_fee->get_name(); if ($fee_name=="Hardcopy-Ticket:") { $noticketsend="YES"; } } //DMS //DMS if (empty($noticketsend)) { //DMS $order->update_status( 'completed' ); //DMS } //DMS } //DMS } ?> -