Okay
  Public Ticket #3671142
Improvements/Inquiries
Closed

Comments

  • Alexandros started the conversation

    Hello there!

    I bought your plugin and so far i am very happy with it..

    i would like your help in order to help everyone and give you some ideas if you would like to hear about so we can make it even better!

    1)

    • I created 8 B2B Groups 
      • B2B +20%
      • B2B +15%
      • B2B +10%
      • B2B +5%
      • B2B -5%
      • B2B -10%
      • B2B -15%
      • B2B -20%
    • Also i kept the B2B initial Group

    First of all i saw in products that i have too many prices now (Regular Price, Sale Price + Tiers for each group.. + the Retail Price, Sale Price etc..) so obviously you can see that this is impossible to track and not lost.. 

    The plan is to have discount Dynamic Rules for the customers of each group.

    In order to do that my plan is to fill only the initial B2B Group Regular Price and with Dynamic Rule i will adjust the rest of the groups taking the price from the initial B2B Group and Raise or Discount that price (ex. for B2B +5% it will calculate the price fromthe B2B Group of the product and Raise it by 5%) and not fill every price for each group separately.
    (keep in mind that groups may be added or deleted and we will have to add again prices for all products for that new group)

    In Dynamic Rules i can see that i have the ability to Raise Price or Discount by percentage. The problem is that it takes the Retail Price of the product instead of choosing which price i would like to calculate from. 

    So if i would like to change a customer from B2B +10% to B2B +5% he will have all the prices instantly and it will be better for our company to manage the B2B Customers by actually using the groups ;)

    2)

    When a guest user wants to create a b2b account in our eshop he will go to the registration page and he will choose from the dropdown the B2B Customer (Requires manual approval) option and the rest of the Registration Fields will show up (so far so perfect). Now i understand that the VAT field is hidden (and why) until the guest user chooses the Country but my proposal is to make the VAT Field (readonly and gray) and unlock it when the customer chooses the Country.

    3)

    Now in order to solve part of the (2) issue i tried to create a simple text, just to inform the guest user to first choose the country in order for the VAT Field to show up, from the Registration Fields from the admin panel menu and i could not. So i would love to see custom Text (like an announcement or comment for the guest to see) and also a button giving it a custom class so i could use it with a combination of a custom function. 

    (for example i created a custom function that if you type a greek VAT number it will ask via webservice the greek goverment and it will autofill the registration fields automatically)

    (so i just created a function doing that, my next move is to make the function work as described in issue (2) )

    4)

    Last but not least for the moment (as i just started configuring your addon and playing around) i would love to see the autofill from the EU(or even better global) VIES by adding some username and password from some webservice API free or for some charge. And of course autofill to the propriate fields (just what i did in our case for greek vat numbers)

    5)

    When a B2B user asks for a quote and the Admin makes the offer, then the user will find that offer in his Quotes section and can add it to cart.

    Let's say that the customer adds to the cart that offer.

    Now it works perfect when the offer includes only one product and adds it in the cart the product comes with it's photo, price of the offer, etc. The problem is when there are many and different products in the offer and they show up as 1 product in the cart without a photo one price for all those products. I would like to see each product to be seperate in the cart/checkout because we sell products not offers. This is major for us.

    6) 

    When a user is created, the username is the first part of the email. As you can imagine, there will be a lot of [email protected] and the usernames from all of them would be info.. so it could be best for all to create some template so we can choose in our preference. For example i would like it to be like info.companyname as the username so it will be easy for us to help our customers if they forget their username and they are on call with us at that moment for example

  •  2,114
    WebWizards replied

    Hello Alexandros,

    Thank you for purchasing our plugin,


    (1)

    In Dynamic Rules i can see that i have the ability to Raise Price or Discount by percentage. The problem is that it takes the Retail Price of the product instead of choosing which price i would like to calculate from. 

    Please note that dynamic rules for 'raise price' and 'discount percentage' start with the group regular price, not the retail price.

    For example, if I have a product configured as follows with a retail price = 100 and group regular price = 500:

    8015122304.png


    Then if we have a 10% raise price rule:

    2299257612.png

    That product will appear as 500 + 10% = $550:

    6291345243.png



    Alternatively, if you prefer to not enter any group prices and just use the dynamic rules, you can simply leave the group price empty:

    6264907689.png

    In that case, B2B users will just get the retail price + dynamic rules, so in this case the price would be $110.


    (2) - (3)

    Regarding the VAT number (which is hidden by default), we can try to see if it's possible to set it as you described (grayed out initially).

    First of all before looking at that, can you please let me know, does your shop sell only in Greece, or perhaps only in the European union?

    If for example you sell only in Greece, then there is a simple solution to just make this field visible by default.



    (4) Regarding Autofill from VIES: Thank you for the suggestion here. I can tell you this is actually something that is already on our roadmap.

    We would like to add this for registration as well as checkout for the 'validate vat' button.

    This is not yet available, but I believe it could be later this year.


    (5) I would like to see each product to be seperate in the cart/checkout because we sell products not offers. This is major for us.

    This is possible by enabling the following setting: in B2BKing -> Settings -> Other, please enable "offers use actual products":

    9330361901.png

    You should then see each product separately in the offer:

    1391822474.png


    (6) 

    When a user is created, the username is the first part of the email. As you can imagine, there will be a lot of [email protected] and the usernames from all of them would be info.. so it could be best for all to create some template so we can choose in our preference. For example i would like it to be like info.companyname as the username so it will be easy for us to help our customers if they forget their username and they are on call with us at that moment for example

    Here you can for example set the username to be identical to the email address, by adding this PHP code snippet:

    add_filter( 'woocommerce_new_customer_data', function( $data ) {
        $data['user_login'] = $data['user_email'];
        return $data;
    } );
    

    I think we can also help with a different format if needed.


    For example i would like it to be like info.companyname 

    The only issue with this format may be that we would then get many usernames such as "michael123.gmail", "john456.gmail", "jim.outlook" etc.



    Looking forward to your response,

    Kind regards,

    Stefan

  • Alexandros replied

    Hello Stefan & WebWizards!

    and thank you for your time and your thoroughly reply!

    Regarding my (1) issue maybe i did not explained it correctly. Let me try one more time :) 

    I did notice that if we have only one b2b group it works as you explained. it takes the wholesale regular price from Dynamic Rules and works perfectly. if it does not find the wholesale Regular Price of that group it takes the Retail Price instead. This is far from what i was asking.

    Let's say we have many B2B Groups (in my case as i explained in (1) ).

    our product page will look like this:

    3072819902.png
    9482218434.png
    3013190875.png

    Now My plan is to create Dynamic Rules for B2B Users +5% and the rest of the B2B Groups and their regular prices will be calculated from the regular price of the initial B2B Users (group)

    for example the regular price of the group B2B Users +5% will be calculated (from dynamic rules) by raising +5% from the regular price of the B2B Users (group). So we will avoid filling all those prices. In this case We will fill only the regular price from the B2B Users (Group) and we will create a Dynamic Rule for the B2B Users +5% (Group) by raising +5% from the Regular Price of the B2B Users (Group). I hope i made it more clear for you 

    (2) - (3) My issue is fixed by adding the follow function so our country is now preselected and the VAT field is being shown.

    function preselect_gr_country() {
        if (is_account_page()) { ?>
            <script type="text/javascript">
                jQuery(document).ready(function($) {
                    $('#b2bking_custom_field_1041').val('GR');
                });
            </script>
        <?php }
    }
    add_action('wp_footer', 'preselect_gr_country');-->
    

    (4) We manage to make the autofill work and works perfectly! (only for greek vat numbers)

    1606282489.gif

    (5) Works perfectly with that option even in beta mode THANK YOU!

    (6) it should do the work i will try it. maybe i change the code a little bit regarding our needs. but Thank you again!

    This is the final function for having the username like info.domain getting it from the email

    add_filter( 'woocommerce_new_customer_data', function( $data ) {
        $email = $data['user_email'];     list( $username, $domain ) = explode( '@', $email );     $user_login = $username . '.' . strtok( $domain, '.' );     $data['user_login'] = $user_login;     return $data;
    } );


  •  2,114
    WebWizards replied

    Hi again Alex, and thank you for your clarifications there,


    (1) Sorry about my confusion, I think I see what you mean now,

    You can indeed add a code snippet to make all B2B users start with the base price of a specific group (in this case the default "B2B Users" group). To do this, you can add the following PHP code snippet to your site:

    add_filter('b2bking_b2b_group_for_pricing', function($user_group, $user_id){
        $is_b2b_user = get_user_meta( $user_id, 'b2bking_b2buser', true );
        if ($is_b2b_user === 'yes'){
            return 1234;
        }
        return $user_group;
    }, 10, 2);
    

    In the above snippet, you must replace 1234 with the ID of the "B2B Users" group. This ID is unique on each site. To find it, go to B2BKing -> Groups -> Business Groups, and click on the group. The number in the URL such as in ?post_id=1234 is the ID of that group.

    It should also work to allow the various +5%, +10% rules start with that B2B users base price.


    -> Great way to make everything else work. The autofill in particular is very cool. Is that a free API webservice anyone can use without authentication? using SOAP? cURL? If you care to share the code, we'd love to take a look : )

  • Alexandros replied

    Hello there,

    thank you for your reply, 

    the snippet did the trick and after some mods i managed to make it work exactly how we would like,

    for example when i was added in the group B2B +10% i was looking the product's price correctly (+10% from the wholesale price of the b2b group id that i want) but when i changed the group to -10% i could see the price as discount price. something that we dont want the customer to see. 

    2713337002.png

    The issue is solved by adding the below snippet ensuring that the price will be hidden even searching a product.

    function hide_b2bking_b2b_price_del() {
        ?>
        <script type="text/javascript">
            document.addEventListener('DOMContentLoaded', function() {
                // Function to hide del elements and remove spans with specific text
                function hideElements() {
                    var b2bPriceElements = document.querySelectorAll('.b2bking_b2b_price_price del');
                    b2bPriceElements.forEach(function(element) {
                        element.style.display = 'none';
                    });
                    var spanElements = document.querySelectorAll('.b2bking_b2b_price_price span.screen-reader-text');
                    spanElements.forEach(function(element) {
                        if (element.textContent.includes('Original price was')) {
                            element.remove();
                        }
                    });
                }
                hideElements();
                var observer = new MutationObserver(function(mutations) {
                    mutations.forEach(function(mutation) {
                        if (mutation.addedNodes.length > 0) {
                            hideElements();
                        }
                    });
                });
                var targetNode = document.querySelector('.live-search-list');
                var config = { childList: true, subtree: true };
                if (targetNode) {
                    observer.observe(targetNode, config);
                }
            });
        </script>
        <?php
    }
    add_action('wp_footer', 'hide_b2bking_b2b_price_del');


    The webservice for searching greek vat numbers is free but in order to get the api username & password you need to be a greek company and you get those codes from our gov.gr. But let's get into it anyway :P I feel nice today :) 

    1) First you need to register to the vies service (you need greek gov credentials). 

    https://www1.aade.gr/webtax/wspublicreg/faces/pages/wspublicreg/menu.xhtml

    2) Then you get the codes from

    https://www1.aade.gr/sgsisapps/tokenservices/protected/displayConsole.htm

    Then you can use the api with SOAP or curl (there is a limit of 100.000 calls/month)

    after getting the codes here is the code i used for the call and the autofill where xxxxxx the credentials from aade

    function check_afm_via_aade() {
        if (!isset($_POST['afm'])) {
            wp_send_json_error('AFM is missing');
        }     $afm = $_POST['afm'];
        if (strpos($afm, 'EL') === 0) {
            $afm = substr($afm, 2);
        }     try {
            $client = new SoapClient("https://www1.gsis.gr/webtax2/wsgsis/RgWsPublic/RgWsPublicPort?WSDL", array('trace' => true, 'exceptions' => true, 'connection_timeout' => 1));
            $authHeader = new stdClass();
            $authHeader->UsernameToken->Username = "xxxxxxx";
            $authHeader->UsernameToken->Password = "xxxxxxx";
            $Headers[] = new SoapHeader('http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd', 'Security', $authHeader, true);
            $client->__setSoapHeaders($Headers);         $options = array('afmCalledFor' => $afm);
            $result = $client->rgWsPublicAfmMethod($options);         $basicInfo = $result['RgWsPublicBasicRt_out'];
            $firmActivities = $result['arrayOfRgWsPublicFirmActRt_out']->RgWsPublicFirmActRtUser;
            if (!is_array($firmActivities)) {
                $firmActivities = array($firmActivities);
            }         $billing_activity = isset($firmActivities[0]->firmActDescr) ? $firmActivities[0]->firmActDescr : '';         $response = array(
                'resp' => $result,
                'afm' => $basicInfo->afm,
                'doyDescr' => $basicInfo->doyDescr,
                'postalAddress' => $basicInfo->postalAddress,
                'postalAddressNo' => $basicInfo->postalAddressNo,
                'postalZipCode' => $basicInfo->postalZipCode,
                'postalAreaDescription' => $basicInfo->postalAreaDescription,
                'legalStatusDescr' => $basicInfo->legalStatusDescr,
                'firmFlagDescr' => $basicInfo->firmFlagDescr,
                'billing_tax_office' => $basicInfo->doyDescr,
                'billing_company' => $basicInfo->onomasia,
                'billing_activity' => $billing_activity,
                'billing_address_1' => $basicInfo->postalAddress . ' ' . $basicInfo->postalAddressNo,
                'billing_city' => $basicInfo->postalAreaDescription,
                'billing_postcode' => $basicInfo->postalZipCode,
            );         wp_send_json_success($response);
        } catch (SoapFault $e) {
            wp_send_json_error('Error: ' . $e->getMessage());
        }
    } add_action('wp_ajax_check_afm_via_aade', 'check_afm_via_aade');


    and here is the autofill with:

    • Readonly to the fields so the customer wont change anything leaving afm field fillable
    • Check if afm is currently valid greek company and if not show a message to the customer for 3 secs.
    function add_afm_check_script() {
        if (is_account_page()) { ?>
            <script type="text/javascript">
                jQuery(document).ready(function($) {
                    $('#b2bking_vat_number_registration_field').on('blur', function() {
                        var afm = $(this).val();
                        if (afm.startsWith('EL')) {
                            afm = afm.substring(2);
                        }                     var data = {
                            'action': 'check_afm_via_aade',
                            'afm': afm
                        };
                        
                        $.post('<?php echo admin_url('admin-ajax.php'); ?>', data, function(response) {
                            if (response.success) {
                                if (response.data.billing_activity === "ΠΡΩΗΝ ΕΠΙΤΗΔΕΥΜΑΤΙΑΣ" || response.data.billing_activity === "" || response.data.billing_activity === null) {
                                    $('#b2bking_vat_number_registration_field').after('<p id="afm-inactive-message" style="color: red;">Ο ΑΦΜ φαίνεται ανενεργός.</p>');
                                    $('#b2bking_field_1098').val(null).prop('readonly', true);
                                    $('#b2bking_field_1035').val(null).prop('readonly', true);
                                    $('#b2bking_field_1036').val(null).prop('readonly', true);
                                    $('#b2bking_field_1039').val(null).prop('readonly', true);
                                    $('#b2bking_field_1038').val(null).prop('readonly', true);                                 setTimeout(function() {
                                        $('#afm-inactive-message').fadeOut('slow', function() {
                                            $(this).remove();
                                        });
                                    }, 3000);
                                } else {
                                    $('#afm-inactive-message').remove();
                                    $('#b2bking_field_1098').val(response.data.billing_tax_office).prop('readonly', true);
                                    $('#b2bking_field_1035').val(response.data.billing_company).prop('readonly', true);
                                    $('#b2bking_field_1036').val(response.data.billing_address_1).prop('readonly', true);
                                    $('#b2bking_field_1039').val(response.data.billing_postcode).prop('readonly', true);
                                    $('#b2bking_field_1038').val(response.data.billing_city).prop('readonly', true);
                                }
                            } else {
                                alert('Error: ' + response.data);
                            }
                        });
                    });
                });
            </script>
        <?php }
    } add_action('wp_footer', 'add_afm_check_script');


  •  2,114
    WebWizards replied

    Hi again,

    Very cool and thank you for sharing all that : ) It would be nice if B2BKing had something like that directly or a Greek extension. Greece is actually our 7th largest customer country for some reason,


    Regarding:

    but when i changed the group to -10% i could see the price as discount price. something that we dont want the customer to see.

    Just to let you know, I think you can also do it with this code snippet here:

    https://woocommerce-b2b-plugin.com/docs/code-snippets-library-list/#13-toc-title


    If there's anything we can do to help, please let us know at any time,

  • Alexandros replied

    Yes!! That's perfect!

    I am going to look at that doc.. seems pretty usefull!!

    Thank you!! our checkout page seems perfect now... :D Keep up the good work guys! i am pretty happy with your support!! 

    If you like to go to our checkout page to take maybe some ideas we implemented and i would like to see them at some point to future updates :) 

    for example at the moment you have the option to make the plugin work hybrid at the same time (b2c, b2b) there are some features you should keep in mind.

    For example:

    a B2C customer should be able to have a reciept or invoice (so the afm should be unlocked)

    8502726450.gif

    On the other hand, b2b customer should not be able to either edit his billing details on his account page (this is the hole point of asking for manual approval, so we could check the validity and/or the company's activity) 

    that's why we disabled the "Edit Billing" information from customer's page 

    function custom_remove_edit_address_link() {
        ?>
        <script type="text/javascript">
            document.addEventListener('DOMContentLoaded', function() {
                if (document.body.classList.contains('b2bking_b2b_user')) {
                    var editAddressLink = document.querySelector('a[href="https://dionicandles.gr/dc-my-account/edit-address/billing/"].edit.button.wc-action-btn.mt-3.px-4');
                    if (editAddressLink) {
                        editAddressLink.remove();
                    }
                }
            });
        </script>
        <?php
    }
    add_action('wp_footer', 'custom_remove_edit_address_link');

    and from the checkout page the b2b customer should not be able to proceed with a reciept but only with invoice ;) and the afm field should be locked (read only) among the other fields

  •  2,114
    WebWizards replied

    Thank you for the great feedback,


    We'll look at how these can be improved this way in future versions,


    Just to let you know, B2BKing can also lock billing fields, but it can only do it for non-standard Billing fields (any fields that are custom-added by B2BKing, such as a VAT number field). This is done by disabling the checkbox here:

    6775244181.png

    (for regular/default Woo fields such as "first name", "address" etc, B2BKing does not have this option).