Public Ticket #3196028

mostrar precios para clientes B2B

Closed
Comments
15 Tickets 7
sistemasdigitales1 started the conversation 4 years ago on December 27, 2022 at 1:08pm

A quien corresponda

Junto con saludar,

Tenemos 2 consultas:
1) Identificar el usuario B2B cuando se loguee en nuestro Ecommerce.
2) Hemos registrado los precios para cliente B2B en los campos recomendados por ustedes ('B2B Users Precio normal', 'B2B Users Precio de venta'), necesitando que cuando el cliente se loguee, muestre esos precios en todo el sitio es decir que el usuario al navegar por nuestro Ecommerce vea cada producto con los precios de B2B.

Observación: Cuando un usuario no es B2B todos los productos del sitio muestran los precios en pesos chilenos. La idea es que cuando un usuario se loguee muestre los precios registrados en los campos de B2B en todo el sitio.

Muchas gracias, quedo atento a su respuesta

David Quiroz
Ofimundo.


2,762
KingsPlugins replied 4 years ago on December 28, 2022 at 2:51pm

Hello David,

1) We can know if a user is B2B or B2C when logged in. 

What would you like to do / show? Do you want to show a message to B2B users, or can you please give me an example of what you want to achieve?

2) Normally that is how the plugin works, when a B2B user logs in, they would see B2B prices. For this to work, it is needed that the customer is placed in a B2B group (on the customer profile page)

I am not sure if I understood your query. Is there a specific issue/ bug you are seeing with this?

Normally our plugin would not have any effect on the currency of the site (Chilean pesos or anything else)

Kind regards,
Stefan

15 Tickets 7
sistemasdigitales1 replied 4 years ago on December 28, 2022 at 7:02pm

Hola Stefan,

En cuanto a la pregunta 2), su respuesta me ayudo a solucionar el problema de la visualización de los precios.

Ahora en cuanto a la pregunta 1), cuando el cliente B2B inicia sesión sus precios los tenemos en dólares y en el momento de pagar los productos, yo debo convertir los precios de dólares a pesos, pero para poder realizar esa operación debo identificar que el cliente sea B2B, por lo tanto existe algún método, función, api, webService, o lo que sea al cual le envié el Rut u otro dato del cliente y me responda que tipo de cliente es la persona que va a pagar?

De antemano muchas gracias por responder y quedo atento a su respuesta

David Quiroz

Ofimundo


2,762
KingsPlugins replied 4 years ago on December 28, 2022 at 7:35pm

Regarding 1)

In PHP, within the website itself, you can use this code snippet:

$user_id = get_current_user_id();
$is_b2b = get_user_meta($user_id,'b2bking_b2buser', true);
if ($is_b2b === 'yes'){
    // B2B user here
} else {
    // B2C user here
}

You can use the above code anywhere on the website to check if the current user is B2B or B2C.


Or do you need this information in a separate system? (I mean if you have a different website API etc where you need this info, but not on the same website).If that is the case, then let me know what information you have: do you have the customer email?



15 Tickets 7
sistemasdigitales1 replied 4 years ago on December 29, 2022 at 1:18pm

Hola Stefan

El código php que me envió esta perfecto, hare las pruebas y si tengo alguna observación se la enviare, de ante mano muchas gracias

David Quiroz

Ofimundo


1
15 Tickets 7
sistemasdigitales1 replied 4 years ago on January 3, 2023 at 3:45pm

Hola Stefan

Junto con saludar y desear un excelente año 2023.

Realice las pruebas con el código que me envió :

$user_id = get_current_user_id();
$is_b2b = get_user_meta($user_id,'b2bking_b2buser', true);
if ($is_b2b === 'yes'){    // B2B user here
} else {    // B2C user here
}

y al ejecutarlo, me dice que las funciones "get_current_user_id" y "get_user_meta" no existen, estas funciones las invoco desde una carpeta child desde el archivo functions.php. Ahora estas funciones las busque en todos los archivos del sitio y no se encuentran.

De antemano muchas gracias, quedo atento a su respuesta,

David Quiroz

Ofimundo






2,762
KingsPlugins replied 4 years ago on January 3, 2023 at 11:06pm

Hi David,

Thank you for your rating, and I would also like to share DISCOUNT15REV2023 for a 15% off of any product on kingsplugins.com


These functions are standard WordPress functions. 

If you get this error, I am thinking maybe WordPress did not load. 

Are you running code separately of WordPress? For example, if you run a PHP file externally of wordpress, for an API,  WEBHOOKS, a CRONJOB, etc, then you need to load WordPress first. To do this, you need to call require_once('wp-load.php'); first before the code snippet.

But then I don't think get_current_user_id() can work in that case.



I am not sure if that is it. 

If you would like, I can check the issue directly. For that, please share a backend website login to the site or a staging site with me, and please explain to me how I can see this error - what steps I can take to see the error? It might help if you have a quick video.


Kind regards,

Stefan

15 Tickets 7
sistemasdigitales1 replied 4 years ago on January 4, 2023 at 3:38pm

Hola Stefan

Junto con saludar, detallo mi problema;

Necesito obtener el id del usuario que inicio sesión en el sitio, un objetivo es saber si este usuario es del tipo B2B o B2C, otro objetivo es obtener la información como dirección, teléfono, email, etc.

Mi ambiente de trabajo es local, 

http://localhost/omdigtal.cl

Para visualizar el sitio ejecuto,



Sobre este escenario cree una carpeta del tipo child la cual se encuentra:

por dominio:    http://localhost/omitech.cl/wp-content/themes/electro-child

físicamente:   C:\xampp\htdocs\omdigital.cl\wp-content\themes\electro-child

Dentro de esta ubicación esta el archivo functions.php, el cual me permite conectarme, ejecutar y programar dependiendo sea el caso diferentes servicios, procesos, hooks, template, css, php, jQuery, etc.


Por lo tanto en el archivo functions.php no me sirve colocar la instrucción que me envías de forma nativa:

 require_once('wp-load.php'); 

Ya que me arroja un error que me dice que la función 'get_id_usuario_actual' no existe. Por lo tanto envió una variable del tipo constante:

ABSPATH = 'C:\xampp\htdocs\omdigital.cl/'

En esta ubicación se encuentra el archivo 'wp-load.php' por lo tanto en el archivo functions.php escribo 2 instrucciones que las ejecuto por separado es decir la que funcione queda, prueba primero:

require_once (ABSPATH).'wp-load.php';

no funciono y ahora pruebo:

include_once ABSPATH . 'wp-load.php';

tampoco funciono.


En ambas ejecuciones separadamente me dice que la función no existe

$id_usuario = get_id_usuario_actual();


Quedo atento a tus observaciones,

David Quiroz

Ofimundo







 

 

2,762
KingsPlugins replied 4 years ago on January 6, 2023 at 5:08am

Hello David,

Thank you for clarifying,


Those functions should work in functions.php

Please try to put your code inside 'add_action('plugins_loaded', function(){ });', like this:

add_action('plugins_loaded', function(){
    $user_id = get_current_user_id();
    $is_b2b = get_user_meta($user_id,'b2bking_b2buser', true);
    if ($is_b2b === 'yes'){    
        // B2B user here
    } else {   
        // B2C user here
    }
});

If it does not work:

-> Please send me your functions.php file so I can review it.


Kind regards,

Stefan

15 Tickets 7
sistemasdigitales1 replied 4 years ago on January 9, 2023 at 11:09am

Hola Stefan

Junto con saludar, gracias por tu ayuda. Bueno haciendo un análisis mas profundo, cambie el hospedaje del sitio es decir de localhost lo subimos a Linux en un ambiente lo mas parecido al de producción y realice las actualizaciones de test que me recomiendas y no tuve un buen resultado por lo tanto te adjunto el archivo functions.php

Esta nueva implementación se llama  "https://omitech.cl" la cual debes forzar su activación debido a que no maneja un certificado de seguridad, el archivo 'wp-load.php' se ubica en :

ABSPATH es una variable constante

ABSPATH  = /var/www/omitech.cl/public_html/ecommerce/wp-load.php

Observación: Al querer subir el archivo functions.php. El 'adjuntar archivo' me dice que no se pueden subir archivos de este tipo por lo tanto le puse functions.gif --> al descargarlo renombrar a functions.php


De antemano muchas gracias y quedo atento a tus observaciones,

David Quiroz

Ofimundo




2,762
KingsPlugins replied 4 years ago on January 9, 2023 at 12:33pm

Hi David,

Thank you for getting back to me,


I think I see the problem. "Google Translate" is playing some games with us. The name of the function is in English. Please see my image below:

The first function does not exist. You must use the second function:

2857023530.png



Please delete the following, as I see it is not related to the issue:

"echo ABSPATH . 'wp-load.php';

require_once ABSPATH . 'wp-load.php';"

15 Tickets 7
sistemasdigitales1 replied 4 years ago on January 10, 2023 at 6:19pm

Hola Stefan,

Junto con saludar, la función funciono muy bien, muchas gracias. 

Ahora que tengo el id del usuario que pertenece a la sesión activa y si este es B2B.

Consulta:

Existe alguna función, api, webService o lo que sea, que pueda para un usuario B2B al entrar en la pagina 'finalizar la compra o checkeout', vea todos los valores en pesos y que cuando haga click a los diferentes tipos de envió, para el seleccionado por ejemplo: chileExpress, al recalcularse se vean en pesos. Es decir que en esta pagina se vean todos los valores en pesos solo para el usuario B2B?

De antemano muchas gracias,

Quedo atento a tus observaciones

David Quiroz

Ofimundo


 

2,762
KingsPlugins replied 4 years ago on January 11, 2023 at 11:08am

Hi David,

I would like to present a few possibilities to you:

1) You could add a multi-currency plugin to the site such as WOOCS . With a plugin like this, every user could choose what currency they want, and switch between different currencies. It an also connect with an API to use a live exchange rate.

2) B2BKing also has 'currency' rules:

https://b2bkingplugin.com/docs/change-currency-for-users-groups/

With these rules you can always force a particular currency for a user or group of users and enter prices directly in that currency.

So for example you can set it so that B2B users always have the 'pesos' currency, and always see prices in pesos.

This feature does not allow changing currencies, and it does not have an exchange rate api - you would need to enter prices in the specific currency manually.

For example:

image-15-2048x821.png

80 = GBP price

100 = Pesos price (or any currency you want)

I do not know of a way to change it only on the checkout page. The above options would change it everywhere (on all pages).

Kind regards,

Stefan

15 Tickets 7
sistemasdigitales1 replied 4 years ago on January 13, 2023 at 2:00pm

Hola Stefan

Junto con saludar, muchas gracias por tu ayuda a nuestras consultas. Se tomo la decisión de tener los precios únicos todos en pesos, así que estamos en contacto ante cualquier consulta.

Gracias,

David Quiroz

Ofimundo



1

Sign In