I have bought the plugin a day ago and want to achieve the following.
Users have the possibility to register during checkout and I have activated the dropdown so that they can select whether they are a B2B or B2C customer (groups are set up in the B2BKing plugin).
The payment method "Auf Rechnung" should only be visible if the user has selected the B2B ("Verein / Geschäftskunde"). If the user has selected B2C ("Privatkunde") they should not have the payment method "Auf Rechnung".
Attached you can find 2 pictures showing the 2 situations.
------------------------------
Another thing I would like to achieve is that the dropdown is the first field in the checkout page.
Depending on whether the user selects B2B or B2C option, the field "Firmenname (optional)" should be shown or hidden.
The plugin cannot currently apply payment methods based on that dropdown - it can only enable/disable methods generally for logged out users. The plugin also doesn't really have any feature that can reorder fields in the checkout page.
The good news is that both of those can be achieved with a JavaScript snippet. I wrote a snippet here that should do that in your site, and it seems to be working in my tests. This is the code:
jQuery(document).ready(function(){
// Move dropdown location
jQuery('.b2bking_registration_roles_dropdown_section').detach().insertBefore('#billing_first_name_field');
jQuery('#billing_company_field').detach().insertBefore('#billing_first_name_field');
function hideInvoice(time = 0){
setTimeout(function(){
if (jQuery('.b2bking_logged_out #b2bking_registration_roles_dropdown').val() === 'role_15515'){
jQuery('.wc_payment_method.payment_method_cheque').css('display','none');
}
}, time);
}
function showHidePriceMethods(){
let chosenacc = jQuery('.b2bking_logged_out #b2bking_registration_roles_dropdown').val();
if (chosenacc === 'role_15514') { // business
// show invoice
jQuery('.wc_payment_method.payment_method_cheque').css('display','block');
// show company name
jQuery('#billing_company_field').css('display','block');
} else if (chosenacc === 'role_15515') { // private
// hide invoice
hideInvoice();
// if invoice already checked, change
if (jQuery('#payment_method_cheque').prop('checked') === true){
jQuery('#payment_method_bacs').click();
hideInvoice(2000);hideInvoice(3500);hideInvoice(5000);hideInvoice(8000);hideInvoice(10000);hideInvoice(12000);hideInvoice(15000);hideInvoice(20000);
}
// hide company name
jQuery('#billing_company_field').css('display','none');
}
}
// if is a logged out user
if (jQuery('.woocommerce-checkout.b2bking_logged_out').val() !== undefined){
showHidePriceMethods();
jQuery('#b2bking_registration_roles_dropdown').on('change', showHidePriceMethods);
}
});
Hello,
I have bought the plugin a day ago and want to achieve the following.
Users have the possibility to register during checkout and I have activated the dropdown so that they can select whether they are a B2B or B2C customer (groups are set up in the B2BKing plugin).
The payment method "Auf Rechnung" should only be visible if the user has selected the B2B ("Verein / Geschäftskunde"). If the user has selected B2C ("Privatkunde") they should not have the payment method "Auf Rechnung".
Attached you can find 2 pictures showing the 2 situations.
------------------------------
Another thing I would like to achieve is that the dropdown is the first field in the checkout page.
Depending on whether the user selects B2B or B2C option, the field "Firmenname (optional)" should be shown or hidden.
See attached picture.
Is that possible?
Thank you for your support and the great plugin!
Kind regards
Roger
Hi Roger,
Thank you for purchasing our plugin,
The plugin cannot currently apply payment methods based on that dropdown - it can only enable/disable methods generally for logged out users. The plugin also doesn't really have any feature that can reorder fields in the checkout page.
The good news is that both of those can be achieved with a JavaScript snippet. I wrote a snippet here that should do that in your site, and it seems to be working in my tests. This is the code:
To add it, you can use our guide here for JS snippets: https://woocommerce-b2b-plugin.com/docs/how-to-add-a-snippet-php-or-js/
I can also set it up for you in the site if you can share a backend login to the site or a staging site.
Kind regards,
Stefan
Hi Stefan,
Wow, what a great service.
Thank you for the snippet it works on my site as well!
Kind regards
Roger
Glad to hear that worked!
Have a good week,