Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Using a function in a module


Recommended Posts

Can anybody help me?

 

Just playing a little bit with Edge...

 

If I take the code

if ($new_price = tep_get_products_special_price($product_info['products_id'])) {
      $products_price = '<del>' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</del> <span class="productSpecialPrice" itemprop="price" content="' . preg_replace('/[^0-9.]*/', '', $currencies->display_price($new_price, tep_get_tax_rate($product_info['products_tax_class_id']))) . '">' . $currencies->display_price($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])) . '</span>';
    } else {
      $products_price = '<span itemprop="price" content="' . preg_replace('/[^0-9.]*/', '', $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']))) . '">' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</span>';
    }

from the product_info.php page and stick it in a product_info module, I get the following error:

 

Fatal error: Call to a member function display_price() on a non-object in/home/myhouse/public_html/edge/includes/modules/content/product_info/cm_pi_specifications.php on line 118

 

Why is that? My brain isn't working today.

osCommerce user since 2003! :thumbsup:

Link to comment
Share on other sites

@@frankl

 

display_price is a "component" of $currencies

 

So you would need to make sure that your new module calls the $currencies prior to using it.

 

Example (product_reviews in product_info.php) https://github.com/gburton/Responsive-osCommerce/blob/master/includes/modules/content/product_info/cm_pi_reviews.php#L36

Calls $oscTemplate, $_GET, $languages_id

 

Do similar but with $currencies. You'd likely also need to call $product_info as well

Link to comment
Share on other sites

@@burt Thank you. I had called $product_info but hadn't followed the logical processes through :blush:
I'll throw in currencies too and finish it.

osCommerce user since 2003! :thumbsup:

Link to comment
Share on other sites

Take a look at the modules in the Modular Product Info addon. They might give you some ideas about what can be done.

 

$_GET is already a superglobal so it doesn't need to be called before you use it. Just take the usual precautions with untrusted data.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...