Skip Address for Virtual Items

  • Posts: 25
  • Thank you received: 2
8 years 8 months ago #232596

-- HikaShop version -- : 2.6.1
-- Joomla version -- : 3.4.8
-- PHP version -- : 5.3.29
-- Browser(s) name and version -- : Chrome 48.0.2564.116

Hi Hikashop,

For checkout process I would like for the system to automatically skip the address entry step if the item bought is virtual, but do not skip if the item bought is shippable.

I've done the following:

1) Force shipping regardless of weight - set to 'NO'
2) Weight of product MGFT001 - all weight and dimensions fields set to '0'

But the address entry step still pops up, how do I solve this issue?

Thank you =)

The following user(s) said Thank You: korzo

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
8 years 8 months ago #232604

Hi,

The address entry still pops up for the billing address. But you should not get it for the shipping address anymore.
The system isn't made to not ask the billing address based on the weight of the products in the cart.
It would require adding the code:
$cart = $this->initCart();
if(!$cart->has_shipping){
return true;
}
after the line:
function after_address($success){
and after the line:
function check_address(){
in components/com_hikashop/controllers/checkout.php
and also after the first <?php in the file "address" of the view "checkout" via the menu Display>Views.

Please Log in or Create an account to join the conversation.

  • Posts: 25
  • Thank you received: 2
8 years 8 months ago #232724

Hi Nicolas,

Thank you for your reply, have applied the code as indicated, but the address fill-in box still pops up.

Code applied after

A] function after_address($success){
B] function check_address(){
C] first <?php in "address" file of "checkout" view under Display->Views

Seems the code removes the shipping address entry and we can also proceed to checkout without entering an address

This is the effect I would like to have:

1) Item is virtual and free - skip billing and shipping address entry completely
2) Item is virtual but not free - request billing and shipping address.
3) Item is shippable and free - request billing and shipping address.
4) Item is shippable and not free - request billing and shipping address.

How do I make the system able to handle the scenarios above automatically?

Thank you =)

Last edit: 8 years 8 months ago by saejangracer.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
8 years 8 months ago #232725

Hi,

Then, instead of:

if(!$cart->has_shipping){
you would need to have:
if(!$cart->has_shipping && $cart->full_total->prices[0]->price_value_with_tax<=0.01){

Please Log in or Create an account to join the conversation.

  • Posts: 25
  • Thank you received: 2
8 years 8 months ago #233191

Hi nicolas,

The address entry pop-up box still appears after adding the new code, there is no way to completely skip the billing address entry part?

EDIT (ADD): Of course I can still manually skip the step by clicking the "X" button at top right corner, and proceed normally with checking out without any address, but it would be great to not have the pop-up box at all for free virtual goods.

Thank you =)

Last edit: 8 years 8 months ago by saejangracer.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
8 years 8 months ago #233195

Hi,

The popup is added only if the address view code is run.
So this means that the process is not entering in the if.
And that means that either !$cart->has_shipping is false, or $cart->full_total->prices[0]->price_value_with_tax<=0.01 is false.
So one of the products in the cart has a weight, or the force shipping regardless of weight setting is activated, or the cart has a price higher than 0.

Please Log in or Create an account to join the conversation.

  • Posts: 25
  • Thank you received: 2
8 years 7 months ago #236150

Hi Nicolas,

I have checked (specifically for Product ID 8 under "Vouchers" category)

The product in the cart does not have a weight - in the product page the weight field is 0.000kg
The force shipping regardless of weight is set to false - in the checkout tab of configuration page
The cart has price of $0 - the cart indicates the item as free, manual shipping also has no price

Is there any other setting I have missed out to not let the address popup activate for case if product is virtual and free?

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
8 years 7 months ago #236225

Hi,

You need to add a var_dump before the line for each condition:

var_dump(!$cart->has_shipping);
var_dump($cart->full_total->prices[0]->price_value_with_tax<=0.01);
if(!$cart->has_shipping && $cart->full_total->prices[0]->price_value_with_tax<=0.01){
That will tell you which one causes the system to skip the if because it is false, and then you can go up from there.

Please Log in or Create an account to join the conversation.

  • Posts: 25
  • Thank you received: 2
8 years 7 months ago #237534

Hi Nicolas,

Thank you for your reply, but I'm still not getting the desired effect for some reason..

The code as you advised has been inserted as shown in Image001, Image002 and Image003.

The configuration settings for product (to ensure no weight) as shown in Image004.

Checkout workflow as shown in Image005.

The configuration settings for cart (force shipping regardless of weight) set to false as shown in Image006.

The address request still pops up for the item that is free (no price) and virtual (no weight) as shown in Image007.

But the address entry is not arbitrary because I can proceed to place my order by closing the address entry pop up as shown in Image008.

The thing is, as the voucher is free and virtual, and the only important thing for the customer to retain is the unique serial code, I don't want the address entry request to pop up at all, whether for billing (nothing to bill as it's free) or shipping (nowhere to ship as it's virtual) address. What do I have to do to achieve that effect? Billing and shipping address entry should STILL pop up for any product that is not free or not virtual.

Thank you for taking the trouble to resolve this =)

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
8 years 7 months ago #237691

Hi,

The var_dumps should display at least on the address view of the checkout.
Are you sure that you edited the address view file for your frontend template and not another template ?

Please also note that we're far from user support. As I said, there is no option to do that by default with HikaShop. We've given hints to do what you want with custom code but if you're not a developer, the best is to ask one to do that for you as it require proper debugging and testing and we can't spend ourselves several hours on custom coding each time someone needs something not possible by default. You can contact our partners if necessary:
www.hikashop.com/home/our-partners.html

The following user(s) said Thank You: saejangracer

Please Log in or Create an account to join the conversation.

  • Posts: 25
  • Thank you received: 2
8 years 6 months ago #240922

Hi nicolas,

Sorry for the confusion, yes you are right, the PHP code was added to the wrong template. Have rectified it!

Added output buffering to remove the bool(true) bool(true) output too:

$cart = $this->initCart();
ob_start();
var_dump(!$cart->has_shipping);
var_dump($cart->full_total->prices[0]->price_value_with_tax<=0.01);
ob_end_clean();
if(!$cart->has_shipping && $cart->full_total->prices[0]->price_value_with_tax<=0.01){
return true;
}

Thank you =)

Last edit: 8 years 6 months ago by saejangracer. Reason: Added code

Please Log in or Create an account to join the conversation.

  • Posts: 1
  • Thank you received: 0
5 years 2 months ago #310686

-- HikaShop Essential version -- : 3.2.1
-- Joomla version -- : 3.9.10
-- PHP version -- : 7.0.33

Hey Nicolas,

Thank you for this explanation, I'm completely searching for this as well. I have only one question, where can I find this part:

the line:
function after_address($success){
and after the line:
function check_address(){
in components/com_hikashop/controllers/checkout.php


And mostly the last sentence: in components/com_hikashop/controllers/checkout.php

I'm quite new at HikaShop and Joomla so sorry for (I hope) this easy question.

Kind regards,
Remco Schelde

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
5 years 2 months ago #310693

Hi,

Note that this thread is 3 years old. 2 years ago we released HikaShop 3.0.0 which came with a brand new checkout system.
In the HikaShop configuration, under the "advanced" tab, you have the "checkout legacy" setting you can activate to go back to the old checkout.
Supposing that you're doing that, and that you do the modifications in components/com_hikashop/controllers/checkout_legacy.php instead of components/com_hikashop/controllers/checkout.php, you might be able to have it working.
However, with the new checkout system, doing this would require completely different modifications.
If you're a developer and want to look at that, you'll want to edit the file "show_block_address" via the menu Display>Views to skip the display of the address area when needed. And you would have to modify the file administrator/components/com_hikashop/helpers/checkout/address.php to validate the address step even without any address entered when needed.

Please Log in or Create an account to join the conversation.

Time to create page: 0.094 seconds
Powered by Kunena Forum