• Hi,

    I’m working with version 0.8.3 of your plugin (which has been great). Is it possible to call a function rather than using the do_shortcode?
    For instance, in the following example, what would be the function to use instead?

    do_shortcode("[ps_product_list id_product=82 tpl=product-grid-exclusives.tpl]");

    A little background: I’m trying to integrate your plugin in an ajax environment (I have too many products to load times are very long and the page freezes until all product info has been loaded).

    I tried using the do_shortcode within wp_ajax, but I get the following error. So I’m trying a different strategy. Any advice is helpful:

    Notice: Undefined variable: products in /wp-content/plugins/prestashop-integration/prestashop-integration.php on line 506
    
    Call Stack:
        0.0004     698568   1. {main}() /wp-admin/admin-ajax.php:0
        0.1997   39995480   2. do_action() /wp-admin/admin-ajax.php:74
        0.1997   39997136   3. call_user_func_array() /wp-includes/plugin.php:406
        0.1997   39997168   4. product_getting() /wp-includes/plugin.php:406
        0.1999   39999576   5. do_shortcode() /wp-content/themes/THEME/functions.php:72
        0.1999   40000224   6. preg_replace_callback() /wp-includes/shortcodes.php:188
        0.1999   40002144   7. do_shortcode_tag() /wp-includes/shortcodes.php:188
        0.2000   40002784   8. call_user_func() /wp-includes/shortcodes.php:273
        0.2000   40002872   9. PrestaShopIntegration->shortcode_ps_product_list() /wp-includes/shortcodes.php:273

    https://www.ads-software.com/plugins/prestashop-integration/

Viewing 1 replies (of 1 total)
  • Plugin Author aytechnet

    (@aytechnet)

    Hi,

    Sorry for my later reply, you may consider this code ?

    $id_product = 82;
    global $prestashop_integration;
    if ($prestashop_integration->psValid()) {
      $products = $prestashop_integration->getProducts($prestashop_integration->psLang(), $id_product);
      if ($products) {
        $prestashop_integration->setTemplateVars( array(
                                            'products' => $products,
                                            'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),
                                            'categorySize' => Image::getSize('category'),
                                            'mediumSize' => Image::getSize('medium'),
                                            'homeSize' => Image::getSize('home') ));
        return $prestashop_integration->fetchTemplate(_PS_THEME_DIR_."product-grid-exclusives.tpl");
      }
    }

    You may include this is an function ? or update it…

    Fran?ois.

Viewing 1 replies (of 1 total)
  • The topic ‘Function instead of shortcode?’ is closed to new replies.