How to show text in checkout based on country and brand

  • Posts: 586
  • Thank you received: 23
  • Hikaserial Subscription Hikashop Multisite
7 years 3 weeks ago #281756

-- HikaShop version -- : 3.2.1
-- Joomla version -- : 3.8.1
-- PHP version -- : 7

Hi Hikashop team,

I like to show text into the checkout step 2 (Address) but I don't know what's wrong with my code.
I want to add this code into checkout / show_block_address.php

The statement is:
When shipping address is country Germany AND one of the products in the cart have (brand) product_manufacturer_id=='28',
then show text or else do nothing. (= text do nothing).

I tried this code but it only show the "text do nothing". Can you please tell me what's wrong with this code.

<?php

if($data->cart->address_country=='country_Germany_81' AND $data->cart->product_manufacturer_id=='28')
{ 
echo "products form the brand x could not be shipped to Germany please remove all brand x products from your cart to order the rest of your prodcuts"; 
}
else
{
echo "text do nothing";
}
?>

I hope you will help me with this :)

Kind regards,
Lumiga


Kind regards,
Lumiga
Last edit: 7 years 2 weeks ago by Lumiga.

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

  • Posts: 12953
  • Thank you received: 1778
7 years 3 weeks ago #281757

Hello Lumiga,

The best solution probably be to directly check what you have in the "$data->cart" object using the "var_dump" function which will enable you to properly check and adapt your PHP condition (if)

Best regards,
Mohamed Thelji.

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

  • Posts: 586
  • Thank you received: 23
  • Hikaserial Subscription Hikashop Multisite
7 years 2 weeks ago #282183

Hi Mohamed,

When I use the "var_dump" function I get NULL in my sreen.

See screenshot:




I use this code:
<?php
var_dump($data->cart);
?>

Do you have an other hint to fix this issue.

Hope you can help me.

Kind regards,
Lumiga


Kind regards,
Lumiga
Attachments:
Last edit: 7 years 2 weeks ago by Lumiga.

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

  • Posts: 12953
  • Thank you received: 1778
7 years 2 weeks ago #282192

Hello Lumiga,

You should actually use the "$this->checkoutHelper->cart->products" variable to have access to the products of your order.

The following user(s) said Thank You: Lumiga

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

Time to create page: 0.097 seconds
Powered by Kunena Forum