Open asiz15 opened 3 years ago
the wc api is very limited for frontend, you aware of that? i am currently working on a wc shop, i use cocart for the heavy lifiting. works pretty well so far, still working on the most complex part, the checkout, but it looks like it gets the job done..
the wc api is very limited for frontend, you aware of that? i am currently working on a wc shop, i use cocart for the heavy lifiting. works pretty well so far, still working on the most complex part, the checkout, but it looks like it gets the job done..
Thanks for your answer, but Im still a bit confused.
Are you using cocart with this theme?
I think I can handle the woocommerce api on my own following the same logic as the theme, using the store.
Could you route the theme correctly for woocommece?, can you provide me an example?
What matters to me for the moment, is to define the appropriate routes to be able to use my vue template in single-product, just like in Single.vue for posts
actually, im ussing this route from permalinks config
https://my-store/products/product-name
thanks!
yes, i use cocart with this theme. like mentioned earlier, wc is not really opening up on products, attributes, prices etc. and with cocart these infos all get exposed to the api. same goes for taxes, shipping, fees, coupons etc. still working on it for the first time, but getting along quite well..
so basically you have issues with getting cpt to work properly, correct?
you need to expose your endpoints inside the rest api data localizer (in the theme this one is found inside functions.php):
new RADL('__VUE_WORDPRESS__', 'vue_wordpress.js', array(
'routing' => RADL::callback('vue_wordpress_routing'),
'state' => array(
...
'products' => RADL::endpoint('products'),
),
));`
and in your template files you need to fetch the data from these endpoints. i pasted this one inside my single.php and for archive it pretty much the same. single:
$post_type = get_post_type();
$post_type === 'post' ? 'posts' : $post_type;
$single = RADL::get('state.' . $post_type, get_the_ID());
archive:
$post_type = get_post_type();
$post_type === 'post' ? 'posts' : $post_type;
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$per_page = RADL::get('state.site')['posts_per_page'];
$posts = RADL::get('state.' . $post_type, ['page' => $paged, 'per_page' => $per_page]);
Hi!
Can anyone point me in the right direction on how can routing properly for woocommerce ? Actually, I follow the steps from [#15], but still not working.
Any solutions? Thanks in advance.