mickert on "[Plugin: WooCommerce] Session chosen shipping methods not working"

ساخت وبلاگ

mickert
Member
Posted 30 minutes ago #

I have a function called wc_csv_export_modify_row_data inside of functions.php. Within this function I check what the chosen shipping method was. I used this code:

$chosen_methods = WC()->session->get( 'chosen_shipping_methods' );
$chosen_shipping = $chosen_methods[0];
if ($chosen_shipping == 'local_delivery') { // do something
} else { // do something else
}

Unfortunately, maybe with the update to version 2.5, this doesn't work anymore. The following error message appears:

Fatal error: Call to a member function get() on a non-object in path/functions.php on line 743

https://wordpress.org/plugins/woocommerce/

When does this code run? Maybe it's too early. It should also only be ran on the frontend, never in admin.

This code will run when its being exported as an csv.

function wc_csv_export_modify_row_data( $order_data, $order, $csv_generator ) {}
add_filter( 'wc_customer_order_csv_export_order_row', 'wc_csv_export_modify_row_data', 10, 3 );

Depending on the chosen shipping method some options will change inside the csv.

WordPress ...
ما را در سایت WordPress دنبال می کنید

برچسب : نویسنده : استخدام کار wpss بازدید : 83 تاريخ : دوشنبه 13 ارديبهشت 1395 ساعت: 17:14