“Warning: Missing argument 2 for WC_Custom_Product” in Woocommerce
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I am migrating a site to a new host and I am getting the following error. I do not quite understand what this error relates to and why it would be fine on the current host but showing this on new hosting despite it being an exact replication using the All-on-one Migration Plugin
Warning: Missing argument 2 for
WC_Custom_Product::action_woocommerce_before_single_product_summary()
in /wp-content/themes/custom-theme/classes/wc-custom-product.php
The function looks like this, there is not a lot to it really but I don't know how to fix
public function __construct() {
$this->product_id = get_the_ID();
$this->product = wc_get_product( $this->product_id );
add_action( 'woocommerce_before_single_product_summary', array($this, 'action_woocommerce_before_single_product_summary'), 10, 2 );
}
function action_woocommerce_before_single_product_summary(
$woocommerce_show_product_sale_flash, $int ) {
echo "<div class='product-row first'>";
}
Any help would be much appreciated
php wordpress woocommerce product hook-woocommerce
add a comment |
I am migrating a site to a new host and I am getting the following error. I do not quite understand what this error relates to and why it would be fine on the current host but showing this on new hosting despite it being an exact replication using the All-on-one Migration Plugin
Warning: Missing argument 2 for
WC_Custom_Product::action_woocommerce_before_single_product_summary()
in /wp-content/themes/custom-theme/classes/wc-custom-product.php
The function looks like this, there is not a lot to it really but I don't know how to fix
public function __construct() {
$this->product_id = get_the_ID();
$this->product = wc_get_product( $this->product_id );
add_action( 'woocommerce_before_single_product_summary', array($this, 'action_woocommerce_before_single_product_summary'), 10, 2 );
}
function action_woocommerce_before_single_product_summary(
$woocommerce_show_product_sale_flash, $int ) {
echo "<div class='product-row first'>";
}
Any help would be much appreciated
php wordpress woocommerce product hook-woocommerce
add a comment |
I am migrating a site to a new host and I am getting the following error. I do not quite understand what this error relates to and why it would be fine on the current host but showing this on new hosting despite it being an exact replication using the All-on-one Migration Plugin
Warning: Missing argument 2 for
WC_Custom_Product::action_woocommerce_before_single_product_summary()
in /wp-content/themes/custom-theme/classes/wc-custom-product.php
The function looks like this, there is not a lot to it really but I don't know how to fix
public function __construct() {
$this->product_id = get_the_ID();
$this->product = wc_get_product( $this->product_id );
add_action( 'woocommerce_before_single_product_summary', array($this, 'action_woocommerce_before_single_product_summary'), 10, 2 );
}
function action_woocommerce_before_single_product_summary(
$woocommerce_show_product_sale_flash, $int ) {
echo "<div class='product-row first'>";
}
Any help would be much appreciated
php wordpress woocommerce product hook-woocommerce
I am migrating a site to a new host and I am getting the following error. I do not quite understand what this error relates to and why it would be fine on the current host but showing this on new hosting despite it being an exact replication using the All-on-one Migration Plugin
Warning: Missing argument 2 for
WC_Custom_Product::action_woocommerce_before_single_product_summary()
in /wp-content/themes/custom-theme/classes/wc-custom-product.php
The function looks like this, there is not a lot to it really but I don't know how to fix
public function __construct() {
$this->product_id = get_the_ID();
$this->product = wc_get_product( $this->product_id );
add_action( 'woocommerce_before_single_product_summary', array($this, 'action_woocommerce_before_single_product_summary'), 10, 2 );
}
function action_woocommerce_before_single_product_summary(
$woocommerce_show_product_sale_flash, $int ) {
echo "<div class='product-row first'>";
}
Any help would be much appreciated
php wordpress woocommerce product hook-woocommerce
php wordpress woocommerce product hook-woocommerce
edited Nov 25 '18 at 11:16
LoicTheAztec
98.7k1472114
98.7k1472114
asked Nov 25 '18 at 3:29
Ben MetcalfeBen Metcalfe
364
364
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
The Woocommerce action hook woocommerce_before_single_product_summary
located in content-product.php
template accepts only one argument and it's mostly never used.
Note that action hooks doesn't need to return an argument as filter hooks does.
Also in your constructor function, you don't need to specify the number of arguments, and as no arguments are used in your hooked function, you can just remove them all just like woocommerce does here and here.
So try this instead:
public function __construct() {
$this->product_id = get_the_ID();
$this->product = wc_get_product( $this->product_id );
add_action( 'woocommerce_before_single_product_summary', array($this, 'action_woocommerce_before_single_product_summary') );
}
public function action_woocommerce_before_single_product_summary() {
echo "<div class='product-row first'>";
}
It should work without errors.
Confirming that this update has worked and I am no longer seeing the error message
– Ben Metcalfe
Nov 25 '18 at 20:32
add a comment |
The way you defined the function it will only work with 2 parameters passed to it. The woocommerce action woocommerce_before_single_product_summary
apparently passes only one parameter, if at all.
So in order to circumvent this you just need to define default values to your parameters in such cases, so that the "missing argument" warning does not fire, like so:
function action_woocommerce_before_single_product_summary(
$woocommerce_show_product_sale_flash = null, $int = 0 ) {
echo "";
}
Notice how for safe measure I defined $woocommerce_show_product_sale_flash as NULL? If the call to action passes any values to this function, the defaults (null and zero) will be overwritten.
Also keep in mind that your "error" is in fact just a warning. It will not break your code and your function should work, but this depends on your PHP error settings, and you probably have warning messages visible or debug mode enabled in WordPress config.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53464405%2fwarning-missing-argument-2-for-wc-custom-product-in-woocommerce%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The Woocommerce action hook woocommerce_before_single_product_summary
located in content-product.php
template accepts only one argument and it's mostly never used.
Note that action hooks doesn't need to return an argument as filter hooks does.
Also in your constructor function, you don't need to specify the number of arguments, and as no arguments are used in your hooked function, you can just remove them all just like woocommerce does here and here.
So try this instead:
public function __construct() {
$this->product_id = get_the_ID();
$this->product = wc_get_product( $this->product_id );
add_action( 'woocommerce_before_single_product_summary', array($this, 'action_woocommerce_before_single_product_summary') );
}
public function action_woocommerce_before_single_product_summary() {
echo "<div class='product-row first'>";
}
It should work without errors.
Confirming that this update has worked and I am no longer seeing the error message
– Ben Metcalfe
Nov 25 '18 at 20:32
add a comment |
The Woocommerce action hook woocommerce_before_single_product_summary
located in content-product.php
template accepts only one argument and it's mostly never used.
Note that action hooks doesn't need to return an argument as filter hooks does.
Also in your constructor function, you don't need to specify the number of arguments, and as no arguments are used in your hooked function, you can just remove them all just like woocommerce does here and here.
So try this instead:
public function __construct() {
$this->product_id = get_the_ID();
$this->product = wc_get_product( $this->product_id );
add_action( 'woocommerce_before_single_product_summary', array($this, 'action_woocommerce_before_single_product_summary') );
}
public function action_woocommerce_before_single_product_summary() {
echo "<div class='product-row first'>";
}
It should work without errors.
Confirming that this update has worked and I am no longer seeing the error message
– Ben Metcalfe
Nov 25 '18 at 20:32
add a comment |
The Woocommerce action hook woocommerce_before_single_product_summary
located in content-product.php
template accepts only one argument and it's mostly never used.
Note that action hooks doesn't need to return an argument as filter hooks does.
Also in your constructor function, you don't need to specify the number of arguments, and as no arguments are used in your hooked function, you can just remove them all just like woocommerce does here and here.
So try this instead:
public function __construct() {
$this->product_id = get_the_ID();
$this->product = wc_get_product( $this->product_id );
add_action( 'woocommerce_before_single_product_summary', array($this, 'action_woocommerce_before_single_product_summary') );
}
public function action_woocommerce_before_single_product_summary() {
echo "<div class='product-row first'>";
}
It should work without errors.
The Woocommerce action hook woocommerce_before_single_product_summary
located in content-product.php
template accepts only one argument and it's mostly never used.
Note that action hooks doesn't need to return an argument as filter hooks does.
Also in your constructor function, you don't need to specify the number of arguments, and as no arguments are used in your hooked function, you can just remove them all just like woocommerce does here and here.
So try this instead:
public function __construct() {
$this->product_id = get_the_ID();
$this->product = wc_get_product( $this->product_id );
add_action( 'woocommerce_before_single_product_summary', array($this, 'action_woocommerce_before_single_product_summary') );
}
public function action_woocommerce_before_single_product_summary() {
echo "<div class='product-row first'>";
}
It should work without errors.
edited Nov 25 '18 at 11:30
answered Nov 25 '18 at 11:09
LoicTheAztecLoicTheAztec
98.7k1472114
98.7k1472114
Confirming that this update has worked and I am no longer seeing the error message
– Ben Metcalfe
Nov 25 '18 at 20:32
add a comment |
Confirming that this update has worked and I am no longer seeing the error message
– Ben Metcalfe
Nov 25 '18 at 20:32
Confirming that this update has worked and I am no longer seeing the error message
– Ben Metcalfe
Nov 25 '18 at 20:32
Confirming that this update has worked and I am no longer seeing the error message
– Ben Metcalfe
Nov 25 '18 at 20:32
add a comment |
The way you defined the function it will only work with 2 parameters passed to it. The woocommerce action woocommerce_before_single_product_summary
apparently passes only one parameter, if at all.
So in order to circumvent this you just need to define default values to your parameters in such cases, so that the "missing argument" warning does not fire, like so:
function action_woocommerce_before_single_product_summary(
$woocommerce_show_product_sale_flash = null, $int = 0 ) {
echo "";
}
Notice how for safe measure I defined $woocommerce_show_product_sale_flash as NULL? If the call to action passes any values to this function, the defaults (null and zero) will be overwritten.
Also keep in mind that your "error" is in fact just a warning. It will not break your code and your function should work, but this depends on your PHP error settings, and you probably have warning messages visible or debug mode enabled in WordPress config.
add a comment |
The way you defined the function it will only work with 2 parameters passed to it. The woocommerce action woocommerce_before_single_product_summary
apparently passes only one parameter, if at all.
So in order to circumvent this you just need to define default values to your parameters in such cases, so that the "missing argument" warning does not fire, like so:
function action_woocommerce_before_single_product_summary(
$woocommerce_show_product_sale_flash = null, $int = 0 ) {
echo "";
}
Notice how for safe measure I defined $woocommerce_show_product_sale_flash as NULL? If the call to action passes any values to this function, the defaults (null and zero) will be overwritten.
Also keep in mind that your "error" is in fact just a warning. It will not break your code and your function should work, but this depends on your PHP error settings, and you probably have warning messages visible or debug mode enabled in WordPress config.
add a comment |
The way you defined the function it will only work with 2 parameters passed to it. The woocommerce action woocommerce_before_single_product_summary
apparently passes only one parameter, if at all.
So in order to circumvent this you just need to define default values to your parameters in such cases, so that the "missing argument" warning does not fire, like so:
function action_woocommerce_before_single_product_summary(
$woocommerce_show_product_sale_flash = null, $int = 0 ) {
echo "";
}
Notice how for safe measure I defined $woocommerce_show_product_sale_flash as NULL? If the call to action passes any values to this function, the defaults (null and zero) will be overwritten.
Also keep in mind that your "error" is in fact just a warning. It will not break your code and your function should work, but this depends on your PHP error settings, and you probably have warning messages visible or debug mode enabled in WordPress config.
The way you defined the function it will only work with 2 parameters passed to it. The woocommerce action woocommerce_before_single_product_summary
apparently passes only one parameter, if at all.
So in order to circumvent this you just need to define default values to your parameters in such cases, so that the "missing argument" warning does not fire, like so:
function action_woocommerce_before_single_product_summary(
$woocommerce_show_product_sale_flash = null, $int = 0 ) {
echo "";
}
Notice how for safe measure I defined $woocommerce_show_product_sale_flash as NULL? If the call to action passes any values to this function, the defaults (null and zero) will be overwritten.
Also keep in mind that your "error" is in fact just a warning. It will not break your code and your function should work, but this depends on your PHP error settings, and you probably have warning messages visible or debug mode enabled in WordPress config.
answered Nov 25 '18 at 3:36
TosheXTosheX
4418
4418
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53464405%2fwarning-missing-argument-2-for-wc-custom-product-in-woocommerce%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown