Caleb Burks on "[Plugin: WooCommerce] One Page checkout plugin with custom checkout fields"

ساخت وبلاگ

Hi there

I am using the Woocommerce One Page Checkout Plugin: https://woocommerce.com/products/woocommerce-one-page-checkout/

I would like to use the methods listed here https://docs.woocommerce.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/ to add a new hidden field to the checkout.

But i don't see it in the code of the one page checkout page: https://www.myhebrewbooks.com/4-minim-aish-la/

Does anyone know if this is compatible (support at Woo has been pretty bad... I have an open ticket on this... maybe you guys can help)

Thanks

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

I used this code: https://docs.woocommerce.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/#section-3, and added a custom field to checkout. Then I tested with OPC, and the field shows up.

So there must be something wrong with your custom code. Perhaps start by adding a visible field or the one listed in the example.

snooper
Member
Posted 32 minutes ago #

Thanks Caleb

here is my code:

/*************************************************************/
function order_origin( $checkout ) {
woocommerce_form_field( 'order_link_origin', array( 'type' => 'hidden', 'value' => get_the_title() , ), $checkout->get_value( 'order_link_origin' ));
}
add_action('woocommerce_after_order_notes', 'order_origin' );
/** * Display field value on the order edit page */
add_action( 'woocommerce_admin_order_data_after_order_notes', 'order_origin_display_admin_order_meta', 10, 1 );
function order_origin_display_admin_order_meta($order){ echo '<p><strong>'.__('Order Origin').':</strong> ' . get_post_meta( $order->id, 'order_link_origin', true ) . '</p>';
}

Type "hidden" isn't a supported option I believe. You can just assign a css class and hide it. And then 'value' isn't an option either, but you can use 'default'.

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

برچسب : نویسنده : استخدام کار wpss بازدید : 497 تاريخ : سه شنبه 19 مرداد 1395 ساعت: 16:24