How to create a landing page after adding a product - php

So i'm working with WordPress and WooCommerce for a website and i have a task that i don't know how to solve. When i create a WooCommerce product i need another landing page for that product to be created automatically where i can see details of the product and similar products.
I was trying to use wp_insert_post() but i can't figure it out how to add the page after adding a product
Is there a way i can do that or is there a plugin that gives you the function to do that?
I hope i was clear in the question.
Thank you in advance

You could try to use the WordPress save_post action: https://codex.wordpress.org/Plugin_API/Action_Reference/save_post
On saving a post, check if the post type is Woocommerce's product post type. If true, you can do whatever you want :)

Related

Add custom form data into ORDER tab (WooCommerce)!

I have created one custom form (Wordpress Woo-commerce) for purchasing products.
I need to insert data into ORDER tab OR After Orders I would like to create one more tab called Subscription Orders same like Orders, but inside this post type data is only for subscription orders.
Can you please guide and help me, How I can achieve this. I have also put screenshots so you can get better idea.
Thank you in advance.
try to override template of woocomerce via themes
and use the hooks.
https://docs.woocommerce.com/document/template-structure/
https://docs.woocommerce.com/wc-apidocs/hook-docs.html

Woocommerce Variations Displayed on Archive Pages

I've got some code working perfectly on my single product pages. For some reason, it will not function the same in archive/list view.
First, I used a plugin to make the variations radio buttons instead of the dropdown. Then I modified that and made it display the price of each variation. Like I said, works great on product page.
I'm new at this google and compile until my eyes bleed and eventually it works. No such luck this time.
Here is the product page: http://pchdelivery.com/product/star-wars-kush/
Here is archive: http://pchdelivery.com/menu/
I don't need any of the cart functionality, only to display the variations and respective price with each product in categories.
Thanks in advance
As per I can understand the issue, you may need to change the settings from the attribute options for the product where you will have to choose the option to not shown in product archive pages.
Screenshot : http://www.awesomescreenshot.com/image/2352336/b6552a6b4d83f8c16efd5935046728c4
Hope it helps.

Unable to display custom fields on archived-product.php WooCommerce Wordpress

I have this problem about my WordPress integration. My problem starts when I start customizing the woo commerce plugin. I make some custom fields using ACF Plugin. My problem is I am not able to display such custom fields on the archived-product.php.
archived-product.php is the shop page right ? But after making some custom fields and point it to ( page == shop ) and calling the custom field with the following code:
<?php the_field('top_image_banner_sub_pages'); ?>
The custom field is still not visible on the archived-product.php. My question is how do I call my custom field so that it would be visible in my shop field ? Your answers are highly appreciated. Thanks a lot Sir/Mam.
Using ACF for this page is a fine idea. I think your problem is your fields are on your "Shop" page, but in actuality the Shop page that WooCommerce is rendering is not associated with the Shop page ID.
The page that is loading is 'archived-product.php' as you mentioned. So you need to tell ACF exactly where to look by entering the ID of your page. So your code should look like this:
<?php the_field('top_image_banner_sub_pages', 123); ?>
Where 123 is replaced by the ID of your Shop page.
Dont use Acf for product custom fields.. please use custom fields of wordpress.
For add meta
https://codex.wordpress.org/Function_Reference/add_post_meta
For get meta
https://codex.wordpress.org/Function_Reference/get_post_meta

How to customize cart item in magento

How can we customize cart items in magento. I have used custom options but it is not working as intended. All I need is to show some configurable data in cart page and in order page.
Can some one help how can I achieve it.
Edit: To elaborate, along with cart item, type and qty. I want to display supporting text for each item type. I got it working with custom options, but I had to include qty inside custom options which created an issue on cart page during cart update. Now I am looking for some other way by which I can acheive same thing.
Thanks
According to your question, you are trying to edit the product that are in the cart. Hope i am getting you right. For this you just need to have a look at the file default.phtml in
app/design/frontend/base/default/template/checkout/cart/item/default.phtml
This phtml file is responsible for displaying the item in the cart. Here you can get the custom options of the product as well. You can edit as per your requirement.
But remember before you edit copy this file to your theme because this is the best practice not to edit the magento's core files.
Hope this will help.

How to display user's WooCommerce subscription details?

I have created a custom page template and I want to display specific details of user's subscription (e.g. subscription starting date).
The available hook on 'my account' page displays this but I don't know how to dismantle the output of the hook or even merely displaying it on a page template.
Any help would be appreciated!
Add the following code in functions.php of the active theme.
add_shortcode('wdm_my_subscription', 'wmd_my_custom_function');
function wmd_my_custom_function(){
WC_Subscriptions::get_my_subscriptions_template();
}
Now use [wdm_my_subscription] as a shortcode on the page where you want to display the User's subscription.
Screenshots:
Without Shortcode:
Adding shortcode:
Result:
If you need to modify the output of this you might need to copy the contains of get_my_subscriptions_template() function WC_Subscriptions class of the WooCommerce subscription Plugin and use it in this shortcode instead which will help you to add the details you want.
After a recent update in the Woocommerce Subscriptions plugin in WordPress
WC_Subscriptions::get_my_subscriptions_template(); is appreciated and it is replaced by new function,
so the old code needs to be updated and the following code needs to be used to create Shortcode to show users subscription
new function should be
add_shortcode('wdm_my_subscription', 'wmd_my_custom_function');
function wmd_my_custom_function(){
WCS_Template_Loader::get_my_subscriptions();
}

Categories