I have a website, and when I go to the WordPress admin page and click on woocommerce-settings it shows this error:
Fatal error: Cannot declare class WC_Settings_General, because the
name is already in use in
/(hosting)/website/wp-content/plugins/woocommerce/includes/admin/settings/class-wc-settings-general.php
on line 0 The site is experiencing technical difficulties. Please
check your site admin email inbox for instructions.
The beginning of class-wc-settings-general.php looks like this:
<?php
/**
* WooCommerce General Settings
*
* #package WooCommerce/Admin
*/
defined( 'ABSPATH' ) || exit;
if ( class_exists( 'WC_Settings_General', false ) ) {
return new WC_Settings_General();
}
/**
* WC_Admin_Settings_General.
*/
class WC_Settings_General extends WC_Settings_Page {
/**
* Constructor.
*/
public function __construct() {
$this->id = 'general';
$this->label = __( 'General', 'woocommerce' );
parent::__construct();
}
/**
* Get settings array.
*
* #return array
*/
public function get_settings() {
etc. The webpage url that is generating this error is: https://www.(mywebsite).com/wp-admin/admin.php?page=wc-settings
I need to know how to resolve this issue and get to the woocommerce settings. I have other websites that have woocommerce and do not have this issue, and I do not know where the other place it is declared would be.
If you need to know the list of plugins, please, let me know.
Please do not flag as a duplicate post as this is a very specific issue regarding woocommerce and WordPress that the other posts I have looked at (around 8 others) do not fix. I have checked for require to change to require_once
Thank you in advance!
I had exactly the same error, except it was pointing to line 0. I switched theme to Storefront and deactivated all plugins except WooCommerce, which fixed the problem... then switched the theme back and gradually added plugins back in to find out which was the problem.
Hopefully this can work for you as well - it was just a conflict with me on an old plugin I thankfully wasn't using any more anyway.
Related
The Error my website displays is below:
Fatal error: Access level to Molla_Element_Section::get_html_tag()
must be protected (as in class Elementor\Element_Section) or weaker in
web.com/public_html/wp-content/plugins/molla-core/elementor/elements/section.php
on line 3668
As per the directory above the code on line 3668 is below:
/**
* Get HTML tag.
*
* Retrieve the section element HTML tag.
*
* #since 1.0
*/
private function get_html_tag() {
$html_tag = $this->get_settings( 'html_tag' );
if ( empty( $html_tag ) ) {
$html_tag = 'section';
}
return $html_tag;
}
Please help me fix this issue , I tried playing with elementor version (downgraded to check if this was the issue) but didn't help.
Take a look at Object Inheritance in php documentation:
The visibility of methods, properties and constants can be relaxed, e.g. a protected method can be marked as public, but they cannot be restricted, e.g. marking a public property as private.
Most likely Molla_Element_Section class inherits from Elementor\Element_Section and overwrites method get_html_tag. But it uses wrong access level.
get_html_tag method cannot be 'private' it has to be 'protected' or 'public'. As documentation says visibility cannot be restricted.
So I went ahead and rolled back the Elementor version to 3.3.1. Currently, everything works stable and the temporary solution seems working fine. If you are facing the same problem, here is what you need to do to downgrade Elementor.
Login to WP-Dashboard > Elementor > Tools > Version Control and Rollback version to 3.3.1
Click “Save” and make sure to clean the browser cache.
You should get a working website now!
I am customising Oxidshop for one of my clients. I want to customise the "changebasket" function in BasketComponent file to add more validations to it.
For this purpose I have also created a custom module. I am trying to extend the class using metadata file.
'extend' => array(
'oxcmp_basket' => \MyVendor\Basket\Application\Components\BasketComponent::class,
),
The BasketComponent file has following code,
<?php
namespace MyVendor\Basket\Application\Components;
/**
* Class LinslinSliderMain.
*/
class BasketComponent extends BasketComponent_parent
{
/**
* #param null $sProductId
* #param null $dAmount
* #param null $aSel
* #param null $aPersParam
* #param bool $blOverride
*/
public function changebasket($sProductId = null, $dAmount = null, $aSel = null, $aPersParam = null, $blOverride = true)
{
echo 'call success';exit;
parent::changebasket($sProductId, $dAmount, $aSel, $aPersParam, $blOverride);
}
}
The gets activated. However, when I refresh any page in frontend, it gets deactivated automatically. I don't know, what's wrong with the code.
EDIT: I am getting this error in oxideshop.log file
Module class MyVendor\Basket\Application\Components\BauerBasketComponent not found. Module ID basket disabled.
depending on your OXID eShop version it might be a different line, but the error message you are stating originates from OxidEsales\EshopCommunity\Core\Module\ModuleChainsGenerator::onModuleExtensionCreationError.
When activating your module, the system tries to generate the class chain with your BasketComponent class in it. As your class is a namespaced class, OXID tries to check if it can find the class via the composer autoload file, if not, the shop throws this exception.
So I assume the module is not installed via composer, at least the namespace seems unknown to composer. You can check in the module documentation on how this should be achieved
Hope I could help
/Flo
As stated in my question, how can i use the function which is inside joomla plugin folder from an external php file?
To be exact, it is under this patch "/plugins/system/rsfppayment/rsfppayment.php" and I want to use the function rsfp_afterConfirmPayment(). I pasted the code snippet below and this file is from rsForm Pro Paypal payment plugin.
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
/**
* RSForm! Pro Payment Plugin
*/
class plgSystemRSFPPayment extends JPlugin
{
function rsfp_afterConfirmPayment($SubmissionId) {
RSFormProHelper::sendSubmissionEmails($SubmissionId);
}
}
You can do the following:
require_once('/plugins/system/rsfppayment/rsfppayment.php');
$objplgSystemRSFPPayment = new plgSystemRSFPPayment();
$objplgSystemRSFPPayment->rsfp_afterConfirmPayment($submissionId);
Of course, you need to make sure that the path is correct and the value of $submissionId is valid.
Post the complete code then you use. The code of itoctopus is correct
I have users who have installed my plugin (we'll call it v6).
V6 version of my plugin does not register a handler for upgrader_process_complete.
In my new version, I have upgrader_process_complete registered to do some upgrades to my database table.
However, it seems that when the user upgrades from the Plugins page using the update now link, the handler of my new version is not invoked.
Could anyone shed some light on this issue?
The upgrader_process_complete hook is running in the current version while updating the plugin.
Let say that you are running plugin v 6.0.
And then you are just updated to 6.1 which contain upgrader_process_complete hook in this version.
The upgrader hook will not be called until next scenario.
Now you have running plugin v 6.1 which contain upgrader_process_complete hook since v 6.1.
And you are just updated to 6.2 which contain the code that write ABC.txt file.
The upgrader hook for 6.1 will be called, NOT 6.2. So, it means that the ABC.txt file will not be created.
If you are running plugin v 6.1 and want to run the newly updated code from 6.2 that just updated, you have to add something like transient to get notice that the update from new version of code is need.
And here is from my plugin. You can use as you need under MIT license.
<?php
class Upgrader
{
/**
* Display link or maybe redirect to manual update page.
*
* To understand more about new version of code, please read more on `updateProcessComplete()` method.
*
* #link https://codex.wordpress.org/Plugin_API/Action_Reference/admin_notices Reference.
*/
public function redirectToUpdatePlugin()
{
if (get_transient('myplugin_updated') && current_user_can('update_plugins')) {
// if there is updated transient
// any background update process can be run here.
// write your new version of code that will be run after updated the plugin here.
}// endif;
}// redirectToUpdatePlugin
/**
* {#inheritDoc}
*/
public function registerHooks()
{
// on update/upgrade plugin completed. set transient and let `redirectToUpdatePlugin()` work.
add_action('upgrader_process_complete', [$this, 'updateProcessComplete'], 10, 2);
// on plugins loaded, background update the plugin with new version.
add_action('plugins_loaded', [$this, 'redirectToUpdatePlugin']);
}// registerHooks
/**
* After update plugin completed.
*
* This method will be called while running the current version of this plugin, not the new one that just updated.
* For example: You are running 1.0 and just updated to 2.0. The 2.0 version will not working here yet but 1.0 is working.
* So, any code here will not work as the new version. Please be aware!
*
* This method will add the transient to work again and will be called in `redirectToUpdatePlugin()` method.
*
* #link https://developer.wordpress.org/reference/hooks/upgrader_process_complete/ Reference.
* #link https://codex.wordpress.org/Plugin_API/Action_Reference/upgrader_process_complete Reference.
* #param \WP_Upgrader $upgrader
* #param array $hook_extra
*/
public function updateProcessComplete(\WP_Upgrader $upgrader, array $hook_extra)
{
if (is_array($hook_extra) && array_key_exists('action', $hook_extra) && array_key_exists('type', $hook_extra) && array_key_exists('plugins', $hook_extra)) {
if ($hook_extra['action'] == 'update' && $hook_extra['type'] == 'plugin' && is_array($hook_extra['plugins']) && !empty($hook_extra['plugins'])) {
$this_plugin = plugin_basename(MYPLUGIN_FILE);// MYPLUGIN_FILE is come from __FILE__ of the main plugin file.
foreach ($hook_extra['plugins'] as $key => $plugin) {
if ($this_plugin == $plugin) {
// if this plugin is in the updated plugins.
// set transient to let it run later. this transient will be called and run in `redirectToUpdatePlugin()` method.
set_transient('myplugin_updated', 1);
break;
}
}// endforeach;
unset($key, $plugin, $this_plugin);
}// endif update plugin and plugins not empty.
}// endif; $hook_extra
}// updateProcessComplete
}
Please carefully read and modify the code above.
In your plugin file, call to Upgrader->registerHooks() method.
And write your code inside redirectToUpdatePlugin() method to work as background update process.
From my code, the procedure will be like this...
Running plugin v 6.0 -> update to 6.1 -> The code in 6.0 set transient that it is just updated.
Reload the page or click to anywhere in admin pages. -> Now v 6.1 is running. -> On the plugin loaded hook, it can detected that this plugin is just updated. -> Call to redirectToUpdatePlugin() method and background process start working here.
TYPO3 was from a very old version updated to TYPO3 6.2. The most things are working now, but I have one own written extension that give me the following error:
Core: Exception handler (WEB): Uncaught TYPO3 Exception: #1297759968: Exception while property mapping at property path "":Could not find a suitable type converter for "String" because no such class or interface exists. | TYPO3\CMS\Extbase\Property\Exception thrown in file /srv/vhosts.d/typo3_src-6.2.9/typo3/sysext/extbase/Classes/Property/PropertyMapper.php in line 106.
I have a list Method in one of the controller that generates a link:
<f:link.action action="show" arguments="{id : course.id}"> {course.name}</f:link.action>
This list method works, but when I want to open this generated link in the website I get the error from above.
I delete all stuff in the showAction method and also change the template to a basic output without special things. The method looks than like this:
/**
* action show
*
* #param String Course-Id
* #return void
*/
public function showAction($id){
}
But the error is still there. I have absolutely no idea anymore what is the problem. It would be great when someone have a different view and properly have some ideas where I can try to find out what the problem really is.
I think it needs to be
/**
* action show
*
* #param string $id Course-Id
* #return void
*/
public function showAction($id){
}
string lowercase and the argument $id must be specified as well
I want to share my solution way:
The first problem was that I don't know that there is a new way to delete the cache of the core. That I find out because of Jost comment in my answer with the "clear the cache from install tool". So I go in the Backend of Typo3 to edit a user and edit there my own under Options the TSconfig field. I add there a row with options.clearCache.system = 1. Now I can clear the system core over the flash symbol in the Backend of Typo3.
After that I try to change the #param String in #param string. I deleted the core cache and then I got a different error. I found out that this new error say that only arrays or objects are as parameters are allowed in the action method (See: http://wiki.typo3.org/Exception/CMS/1253175643).
So I deleted the parameter and follow the instruction on the website where the error is explained. So my new method looks as follow:
/**
* action show
*
* #return void
*/
public function showAction(){
if ($this->request->hasArgument('id')) {
$id= $this->request->getArgument('id');
}
// Do stuff with the id
}
And that works now :)