This topic contains a post which is marked as Best Answer. Press here if you would like to see it.
*

Tango

  • ****
  • 212 posts
How to check if shipping is enabled for an item?
« on: August 09, 2022, 12:10:47 AM »
Hello,

I would like to show an icon on the listing page, when that listing is for sale and has shipping enabled.

So what is the function that returns if an item has shipping enabled or not?

I tried something like:
Code: [Select]
<?php if(function_exists('osp_product_to_cart_link') && osp_param('enable_shipping') == ) { ?>
...
But it shows the icon on all listings, not just for those that have shipping enabled.

Any ideas?
Thanks!

*

MB Themes

Re: How to check if shipping is enabled for an item?
« Reply #1 on: August 09, 2022, 10:13:59 AM »
@Tango
You must get osp item data record and check if shipping is set to yes.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Tango

  • ****
  • 212 posts
Re: How to check if shipping is enabled for an item?
« Reply #2 on: August 10, 2022, 07:39:49 PM »
Yeah, I tried the following but with no luck:
Code: [Select]
$item['fk_i_item_id'] = isset($item['fk_i_item_id']) ? $item['fk_i_item_id'] : 0;
$item_data = ModelOSP::newInstance()->getItemData($item['fk_i_item_id']);

if(isset($item_data['i_shipping']) && $item_data['i_shipping'] == 1) {
...

I don't know what I'm missing...

*

MB Themes

Re: How to check if shipping is enabled for an item?
« Reply #3 on: August 16, 2022, 11:24:13 AM »
@Tango
Looks good, make sure you are getting item id properly
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Fabio Massaro

  • *****
  • 291 posts
Re: How to check if shipping is enabled for an item?
« Reply #4 on: October 14, 2022, 08:40:45 AM »
Yeah, I tried the following but with no luck:
Code: [Select]
$item['fk_i_item_id'] = isset($item['fk_i_item_id']) ? $item['fk_i_item_id'] : 0;
$item_data = ModelOSP::newInstance()->getItemData($item['fk_i_item_id']);

if(isset($item_data['i_shipping']) && $item_data['i_shipping'] == 1) {
...

I don't know what I'm missing...


Hi @tango could you help me I wanted to put an icon on items with shipments too

Marked as best answer by frosticek on October 14, 2022, 09:37:19 AM
*

Tango

  • ****
  • 212 posts
Re: How to check if shipping is enabled for an item?
« Reply #5 on: October 14, 2022, 09:15:53 AM »
Code: [Select]
            <?php
              
if(function_exists('osp_install')) {
                
$item_data ModelOSP::newInstance()->getItemData(osc_item_id());

                if(isset(
$item_data['i_shipping']) && $item_data['i_shipping'] == 1) { ?>

                  // Your icon code here
                <?php ?>
            <?php ?>
You can apply this wherever you want.
Good luck!