0

I have a webshop made with drupal commerce kickstart and use it as a POS in a bar. The people pay with cash. What i want is a calculator with 2 input fields: field 1: the "Order total" from checkout automatic comes in this field. Field 2 is the amount of cash the customer pays with. So i can see how much i have to return to the customer. I have webform calculator installed. But the big question is how to automatic place the value from Order total in the calculator.

0

If you already have a calculator that you like and the commerce portion is working the way you want it, the best thing to do is probably to change as little as possible. My first thought is to use a simple javascript that looks for the field where commerce stores the order total and copy it into your webform field. In my kickstart staging environment, there is a field called "ajax-item-price". So you could do a jquery one-liner like

$('#name-of-your-webform-field').val($('#ajax-item-price').html());
  • Thx for the quick response. It looks like a good solution. But how do i put that jquery in the webform field? I am notgood with writing code. But is it something like: jamestombs.co.uk/2012-09-24/create-new-webform-element-drupal-7 – user24924 Oct 20 '14 at 16:51
  • Ah, sorry: With a drupal_add_js() call in your hook_form_alter() implementation. But it sounds like you already have a different way of doing it. – Klaus Sonnenleiter Oct 20 '14 at 21:41
0

I found a solution myself. I have 3 fields in the webform calculator: Field 1: payed with (the amount the customer pays with, for example he pays with 20 Euro) Field 2: with token: [site:current-cart-order:commerce-order-total:amount_decimal] it fills the field automatic Field 3: a formula {payed-with}-(name of field 2} Thats it. Now i have a working cash register for a Drupal webshop.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.