Add private note after checkout in Woocommerce - woocommerce

I've setup a custom function by using the woocommerce_thankyou hook.I want to add a private note during this function.
How Can I implement this?

Related

Prestashop 1.7 override front controller from custom theme

In PrestaShop 1.7, I have my own theme, which is currently the default.
In the product card, I need to display a list of multishop stores.
Since I don't know if it is possible to get information about multishop stores using the default controller controllers/front/ProductController.php, I want to extend this controller in my custom theme.
I am creating file themes/myTheme/override/controllers/front/ProductController.php with code like this:
class ProductController extends ProductControllerCore{
public $multiStores;
public function init()
{
parent::init();
echo 'test';
}
}
I expect that on the product card page I will be able to see my text "test".
But unfortunately nothing happens, I conclude that this controller is not connected for some reason.
Can you please tell me what I'm doing wrong and how to fix the situation?
You cannot override a front controller method in a theme like that.
You'll need to override the core frontcontroller by placing
your code inside /override/controllers/front
See : https://devdocs.prestashop.com/1.7/modules/concepts/overrides/
Anyway you can achieve the desired result in a cleaner way by
using a proper frontend hook (ie. hookDisplayHeader) and build a simple module, checking the context object to see in which id_shop you are connected.

Why is admin_options not called in WooCommerce Payment Gateway Extension

I'm creating a custom payment gateway for WooCommerce, but I'm struggling to display the settings in de admin area.
I've followed tutorials like:
https://docs.woocommerce.com/document/payment-gateway-api/
https://docs.woocommerce.com/document/settings-api/
https://rudrastyh.com/woocommerce/payment-gateway-plugin.html.
However in my case admin_options is just never called when I go to the settings page for my payment gateway.
The payment gateway is in the list of payment methods. It's also visible in the frontend as selectable payment method.
Inside my class that extends WC_Payment_Gateway I have put
public function admin_options() {
echo 'TEST';
die();
}
To check if it's called, but it isn't. Other methods like the constructor, init_form_fields are called, so at least some part is working.
Any ideas on what might be happening or how to tackle this are very welcome.
$this->id contained some uppercase letters....it seems that was not allowed...making it lower case resolved the issue.
I was triggered by the answer of #Vishal in this post:
WordPress Plugin WooCommerce, Custom Payment Gateway Settings Not Saving

How to call WordPress plugin function from custom page template?

I have a custom WordPress plugin that handles authentication.
There's a function logTheUserIn() inside plugin-name/src/Classes/Auth.php.
I need this function to be run when a user hits a custom WordPress template page (page-authPortal.php), which has this code at the top:
include_once('wp-includes/pluggable.php');
include_once("wp-content/plugins/ad-auth-bridge/src/Classes/Auth.php");
print "test";
I created a WordPress page titled "authPortal" and it shows the 'test' text, so I know the custom page is being loaded and rendered. Now I just need to fire off logTheUserIn().
I have tried adding shortcodes and actions inside Auth.php:
class Auth {
public function InitHooks() {
add_shortcode ('authNow', 'logTheUserIn');
add_action ('authAction', 'logTheUserIn');
I've then tried to use the actual shortcode [authNow] inside the WordPress editor, I have also tried do_shortcode and do_action.
What am I missing here?
Thank you!
There is no need to include or require the plugin fields. They are initially loaded by WordPress.
First, in your template, make sure your plugin is active and the function/class is reachable:
if ( function_exists( 'logTheUserIn') ) {
logTheUserIn();
}
Then fire the function right within your template.
In your case, you might need to check if class_exists, then initialize the class

Change Woocommerce Email Header using custom plugin

I want to change the WooCommerce email header template with a new one so that i could add conditions in header template to get value from dashboard or database. (To change color of header based on user input from dashboard). Please note that i am using a custom plugin file to do so.
I have followed several tutorials and all i received was bunch of errors.
What i did is, i have a class with following code.
public function __construct(){
add_action('woocommerce_email',array($this,'woocommerce_email'));
}
Now I have added code to remove default reset the hook:
public function woocommerce_email($mailer){
remove_action('woocommerce_header',array($mailer,'email_header'));
add_action('woocommerce_header',array($this,'email_header'));
}
Now calling the template:
public function email_header() {
wc_get_template( 'emails/email-header.php');
}
I am not passing anything to the template file. So no parameters are passed to functions. I just wanted to see that my template is being taken.
Also i assume $mailer to be a part of WooCommerce class.
Any help would be appreciated.
Please note that this is a plugin functionality so I am not interested in replacing the WooCommerce email templates.

Wordpress posts on magento

I have a magento store. I want to add a blog site(www.example.com/blog) on it using wordpress. For this, i am using Fishpig's Wordpress Integration 2.2.7. I wanted to have a different template for my blog site.
So, i have created a separate template for wordpress blog page. On the top of the page, i want to add recent posts slider i.e, i want to display a featured image of the post with few lines of the content with read more option. Additional information like author, published date will also be there with the content.
How can i implement this on the blog page template?
Also my blog sites menu navigation will be different from store's menu navigation.
How can i implement this? Is it possible to do so with this plugin or any other?
Please suggest me the best.
Thanks in advance.
You need to retrieve the image resource, then get the image url
$_image = $_post->getFeaturedImage();
echo $_image->getAvailableImage();
Take a look at Fishpig/Wordpress/Model/Image.php for more url methods:
public function getThumbnailImage()
public function getMediumImage()
public function getLargeImage()
public function getFullSizeImage()
public function getPostThumbnailImage()
public function getAvailableImage()
public function getImageByType($type = 'thumbnail')
To get the featured post image you can use
$post->getFeaturedImage();
Where $post is the Fishpig Wordpress post Collection object. Here is an example of getting a post where category_id = 3:
$col_posts = Mage::getResourceModel('wordpress/post_collection')
->addIsPublishedFilter()
->addCategoryIdFilter(3);
$col_posts->getSelect()->limit(1);
$post = $col_posts->getFirstItem();
You can customize your select using magento EAV on the collection above or see the methods available at Fishpig/Wordpress/Model/Archive.php.
And if you want to put a recent post block, take a look at http://fishpig.co.uk/wordpress-integration/docs/recent-posts-block.html.

Resources