WooCommerce checkout-procedure aanpassen in code
Versie door Jeroen Strompf (overleg | bijdragen) op 8 apr 2018 om 16:37 (→Voorbeeld: Factuur-velden aanpassen)
Dit artikel: Hoe je in code de WooCommerce-afrekenprocedure kunt aanpassen. Zie Eigen code toevoegen (WordPress) voor andere mogelijkheden (ihb. mbv. plugins).
Voorbeeld: Factuur-velden aanpassen
De Code Snippets-plugin geïnstalleerd om gemakkelijk code te incorporeren in de site. Code:
<?php // Change WooCommerce's checkout procedure to only // issue quotes and no actual purchases // // * Jeroen Strompf - De Vliegende Brigade, April 2018 // * Based on example from https://www.skyverge.com/blog/how-to-simplify-free-woocommerce-checkout/ // ////////////////////////////////////////////////// // Basic function ////////////////////////////////////////////////// // // Everything's done through this function // function dvb_experiment_with_checkout_fields() { // Verify that we're at checkout /////////////////////////////////////// // // Check that there actually is a checkout + // we're not on it // if (function_exists('is_chekcout') && (! is_checkout)) { // We're not at chekcout > Leave //////////////////////////////// // return; } // Unset the fields we don't want in a free checkout // function unset_unwanted_checkout_fields( $fields ) { // Compile a list of unwanted fields // Source: http://docs.woothemes.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/#section-2 /////////////////////////////////////////////////// // $billing_keys = array( 'billing_company', 'billing_phone', 'billing_address_1', 'billing_address_2', 'billing_city', 'billing_postcode', 'billing_country', 'billing_state', ); // Unset each of those unwanted fields ////////////////////////////////////// // foreach( $billing_keys as $key ) { unset( $fields['billing'][$key] ); } return $fields; } // Add filter to remove unwanted fields /////////////////////////////////////// // add_filter( 'woocommerce_checkout_fields', 'unset_unwanted_checkout_fields' ); } /////////////////////////////////////////////////////// // Add action /////////////////////////////////////////////////////// // // Only declaring a function, doesn't do anything // You somehow have to execute that funciton // In this case, that's through this filter // add_action('wp','dvb_experiment_with_checkout_fields');
Betaalscherm overslaan
Simpel:
add_filter('woocommerce_cart_needs_payment', '__return_false');
De WC Direct Place Order Without Payment heeft dit in een module gestopt. Zie WooCommerce & quote-only voor details.