How To Render Product View Page

I tried to render product view page, but whenever I am trying to render page it is not rendering.

I returned url of product page with product id.

I used class="cm-ajax cm-ajax-full-render" but still not working.

Kind Regards-

himanshu

How or what page from do you render the Product View page?

In product view page I added qty tpl hook.

Currently I am in product view page where product id=12.

In this hook there is a submit button which is submitted to my controller.

E.g.

== qty.post.tpl ==

{a=function_abc()}

{if a==1}

hello

{else}

bye

{/if}

Now function_abc() returns 1 or 2 according to condition.

When I click on button it should change text to "hello or "bye".

In my case my_mode returns dispatch=product.view&product_id=12

and I am currently in same page.

-Himanshu

In above case my tpl is not rendering.

It should be included in one of the 'result_ids' block. Or you should add your element's id to the 'result_ids' of ajax request.

Or include cm-reload to class.

Hi there,

I will try your sugestion and reply with result.

-Himanshu

Hello,

I tries both method but none are effective

  • I tried cm-reload
  • included my element's id to the result_ids still no effect

I cannot render product page mode="view"

In 100g pant when we change color option, product image changes without refreshing page but uses external js file for this change

I want to do it as cs cart does it in checkout page.

-Himanshu

The common scheme for AJAX-refreshing is the following:

1. You have some div (or another element with id) which should be refreshed. It should have closing comment:

... some content ... {$smarty_var} is displaying

2. When you are forming a requirest, it should look like the following:

$.ceAjax('request', url, {'result_ids': 'refresh_me', 'full_render': true});

url should contain controller and mode with parameters which process the data and push it back to $smarty_var.

result_ids should contain all ids which should be refreshed after request is performed. If there are several ids, they should separated by ','. For example, 'id1,id2,id3'.

3. In the controller you should do something (or not), pass the data to $smarty_var (in our case) or to any other variables and force your tpl to be displayed.

You can use this expression:

Registry::get('view')->display('addons/your_addon/views/your.tpl');

It can be any tpl which includes the data you want to refresh.

You can even display directly 'views/products/view.tpl'

4. After tpl is displayed you should stop rendering the standard template. But controller should be stopped only if it is AJAX request.

So it can be look like the following:

if (defined('AJAX_REQUEST')) {
    Registry::get('view')->display('addons/your_addon/views/your.tpl');
    exit;
}

Also switch on the browser console to be sure that your request is properly sent, includes valid parameters and returns valid values. Among the others there should be 'html' returned value.

Hello,

Method explained above is only useful if we are sending ajax call by outself.

In my case I want to use cs cart default cm-ajax cm-ajax-full-render class to render my block.

What do we do if we want to render any particular block or full page without refreshing.?

-himanshu

Then it is not clear enough how and what should be done.

hi again i have similar problem.

i am try render account info summary on checkout page but i have no luck i tried everything

i am adding payment_surcharge to cart session, its coming from my payment gateway

here is php file

if (defined('AJAX_REQUEST')) {
            Tygh::$app['view']->assign('cart', Tygh::$app['session']['cart']);
            Tygh::$app['view']->display('blocks/checkout/summary.tpl');
            exit;
        }

and tpl file


i try every result_ids but no luck

ihave checked turn value and cart array vie debug log values turn back correctly

but it doesnt render block

what can i do ?

also i disable block cache from config. also i try result ids with block number like checkout_info_summary_277

iam try with views working (reloading some tpl)

i am try same as with block tpl. nothing.

whats wrong ?

fixed with adding static block.