I get the following error when trying to access my newly updated webpage. it is now runing php 7.2.
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘create_my_post_types’ not found or invalid function name in /home/2/l/lysefjordensjokj/www/wp-includes/class-wp-hook.php on line 286
Warning: Cannot modify header information – headers already sent by (output started at /home/2/l/lysefjordensjokj/www/wp-includes/class-wp-hook.php:286) in /home/2/l/lysefjordensjokj/www/wp-includes/pluggable.php on line 1223
I know nothing about any code or programming. Anyone know if this is a quick fix.
You need to find out which plugin (or theme) is doing this and then look for an update.
This may be a plugin or theme conflict. Please attempt to disable all plugins, and use one of the default (Twenty*) themes. If the problem goes away, enable them one by one to identify the source of your troubles.
If you can install plugins, install “Health Check”:https://wordpress.org/plugins/health-check/On the troubleshooting tab, you can click the button to disable all plugins and change the theme for you, while you’re still logged in,without affecting normal visitors to your site. You can then use its admin bar menu to turn on/off plugins and themes one at a time.
Also, edit your wp-config.php and make sure WP_DEBUG is set to false, not true.
However, when I try to do it in a dynamic manner with variables, it doesn't work. I even tried casting the variables tointto make sure they are they right type.
First:do use$wpdb->delete. It handles a lot of theprepare, etc. behind the scenes. Second: what do you get when youvar_dump($id)? orvar_dump($time)? The problem isalmost certainlyrelated to the values in those variables.
This is probably the most correct solution. Those using DELETE FROM will work, but that isn't how wpdb is intended to work. A little explanation would work - the critical piece being the user of array('%d') which converts the integer appropriately.
Code-only answers are not useful. Why does this work, where OP's code doesn't? Further, this iswide opento SQL injection. Don't post answers that are open to this sort of security attack.
Want to create a plugin to extend WooCommerce? WooCommerce plugins are the same as regular WordPress plugins. For more information, visitWriting a plugin.
Your WooCommerce extension should:
Adhere to all WordPress plugin coding standards, as well asbest practice guidelinesfor harmonious existence within WordPress and alongside other WordPress plugins.
Have a single core purpose and use WooCommerce features as much as possible.
Not do anything malicious or underhanded — for example, inserting spam links or up selling services outside of the WooCommerce.com ecosystem.
Not subvert or override Marketplace connections in core — for example, extensions cannot create branded top level menu items or introduce their own telemetry.
Merchants make use of WooCommerce extensions daily, and should have an unified and pleasant experience while doing so without advertising invading their WP Admin or store.
Note: We provide this page as a best practice for developers.
Note:We are unable to provide support for custom code under ourSupport Policy. If you are unfamiliar with code and resolving potential conflicts, select aWooExpert or Developer for assistance.
Check if WooCommerce is active
Most WooCommerce plugins do not need to run unless WooCommerce is already active. You can wrap your plugin in a check to see if WooCommerce is installed:
/** * Check if WooCommerce is active **/ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) { // Put your plugin code here }
Note that this check will fail if the WC plugin folder is named anything other thanwoocommerce.
Main file naming
The main plugin file should adopt the name of the plugin, e.g., A plugin with the directory nameplugin-namewould have its main file namedplugin-name.php.
Text domains
Follow guidelines forInternationalization for WordPress Developers, the text domain should match your plugin directory name, e.g., A plugin with a directory name ofplugin-namewould have the text domainplugin-name. Do not use underscores.
Localization
All text strings within the plugin code should be inEnglish. This is the WordPress default locale, and English should always be the first language. If your plugin is intended for a specific market (e.g., Spain or Italy), include appropriate translation files for those languages within your plugin package. Learn more at Using Makepot to translate your plugin.
Follow WordPress PHP Guidelines
WordPress has aset of guidelinesto keep all WordPress code consistent and easy to read. This includes quotes, indentation, brace style, shorthand php tags, yoda conditions, naming conventions, and more. Please review the guidelines.
=== Plugin Name === Contributors: (this should be a list of wordpress.org userid's) Tags: comments, spam Requires at least: 4.0.1 Tested up to: 4.3 Requires PHP: 5.6 Stable tag: 4.3 License: GPLv3 or later License URI: http://www.gnu.org/licenses/gpl-3.0.html
Plugin Author Name
Consistency is important to us and our customers. Products offered through WooCommerce.com should provide a consistent experience for all aspects of the product, including finding information on who to contact with queries.
Customers should be able to easily to differentiate a product purchased at WooCommerce.com from a product purchased elsewhere, just by looking through their plugin list in WordPress.
Thus, the following plugin headers should be in place:
ThePlugin AuthorisYourName/YourCompany
TheDeveloperheader is YourName/YourCompany, with theDeveloper URIfield listed ashttp://yourdomain.com/
For example:
/** * Plugin Name: WooCommerce Extension * Plugin URI: http://woocommerce.com/products/woocommerce-extension/ * Description: Your extension's description text. * Version: 1.0.0 * Author: Your Name * Author URI: http://yourdomain.com/ * Developer: Your Name * Developer URI: http://yourdomain.com/ * Text Domain: woocommerce-extension * Domain Path: /languages * * Woo: 12345:342928dfsfhsf8429842374wdf4234sfd * WC requires at least: 2.2 * WC tested up to: 2.3 * * License: GNU General Public License v3.0 * License URI: http://www.gnu.org/licenses/gpl-3.0.html */
Declaring required and supported WooCommerce version
Use the follow headers to declare “required” and “tested up to” versions:
WC requires at least
WC tested up to
Plugin URI
Ensure that thePlugin URIline of the above plugin header is provided. This line should contain the URL of the plugin’s product/sale page on WooCommerce.com (if sold by WooCommerce) or to a dedicated page for the plugin on your website.
Woo Plugin Header For Updates
WooCommerce core looks for aWooline in the plugin header comment, to ensure it can check for updates to your plugin, on WooCommerce.com. This line looks like this:
Woo: 12345:342928dfsfhsf8429842374wdf4234sfd
This isonly required for products sold on WooCommerce.com. Using this line for products listed on WordPress.org or elsewhere is not required or necessary.
For products sold on WooCommerce.com, Vendors can find this snippet by logging in to their logging in to the Vendors Dashboard and going toExtensions > All Extensions. Then, selectthe product and clickEdit product page. This snippet will be in the upper-right-hand corner of the screen.
See the plugin header comment example above for how theWooheader looks in context.
Make it Extensible
Developers should use WordPress actions and filters to allow for modification/customization without requiring users to touch the plugin’s core code base.
If your plugin creates a front-end output, we recommend to having a templating engine in place so users can create custom template files in their theme’s WooCommerce folder to overwrite the plugin’s template files.
With version control, there’s no reason to leave commented-out code; it’s annoying to scroll through and read. Remove it and add it back later if needed.
Comment
If you have a function, what does the function do? There should be comments for most if not all functions in your code. Someone/You may want to modify the plugin, and comments are helpful for that. We recommend usingPHP Doc Blocks similar toWooCommerce.
Avoid God Objects
God Objectsare objects that know or do too much. The point of object-oriented programming is to take a large problem and break it into smaller parts. When functions do too much, it’s hard to follow their logic, making bugs harder to fix. Instead of having massive functions, break them down into smaller pieces.
Test Your Code with WP_DEBUG
Always develop withWP_DEBUGmode on, so you can see all PHP warnings sent to the screen. This will flag things like making sure a variable is set before checking the value.
Separate Business Logic & Presentation Logic
It’s a good practice to separate business logic (i.e., how the plugin works) frompresentation logic(i.e., how it looks). Two separate pieces of logic are more easily maintained and swapped if necessary. An example is to have two different classes — one for displaying the end results, and one for the admin settings page.
Use Transients to Store Offsite Information
If you provide a service via an API, it’s best to store that information so future queries can be done faster and the load on your service is lessened.WordPress transients can be used to store data for a certain amount of time.
Logging Data
You may want to log data that can be useful for debugging purposes. This is great with two conditions:
Allow any logging as an ‘opt in’.
Use theWC_Loggerclass. A user can then view logs on their system status page.
If adding logging to your extension, here’s a snippet for presenting a link to the logs, in a way the extension user can easily make use of.
This information is intended for the third-party developers so products they write can better handle errors. Error codes are produced by the Product Build Server when uploading a new submission or updating an existing product on the Marketplace.
error_success
The operation has completed successfully.
error_pbs_prepare_apache
Internal error with the Product Build Server – cannot initialize the Apache daemon.
error_pbs_prepare_mysql
Internal error with the Product Build Server – cannot initialize the MySQL daemon.
error_pbs_prepare_wp
Internal error with the Product Build Server – cannot initialize WordPress.
error_pbs_prepare_wc
Internal error with the Product Build Server – cannot initialize WooCommerce.
error_pbs_prepare_dependencies
Internal error with the Product Build Server – cannot configure dependencies.
error_pbs_test_malware_scanning
Malware scanning error. This can happen if your product contains malware in the code.
This means that the character at the absolute position 0x406 (1030) and 0x506 (1286) in the filehtml-settings-page.phpdoesn’t pass the$ini_setrule, because it is usingcall_user_funcin that file. Also, the other filehtml-extras-page.phpdoesn’t pass the rule$register_functionwhich is usingexeccall.
error_pbs_test_extracting
Cannot extract the product. Most common issue is the top directory of the zip does not match its slug.
error_pbs_test_phpcs
phpcschecks failed. The check uses theWooCommerce-Coresniffs with followingphpcs.xml:
Cannot install the product. Most common issue is the top directory of the zip does not match its slug.
error_pbs_test_activating
Cannot activate the product. Refer to the build output for more details.
error_pbs_test_deactivating
Cannot deactivate the product. Refer to the build output for more details.
error_pbs_test_host_plan_installing
This error means that your product is incompatible with other products in the host plan. Refer to the build output for more details.
error_pbs_test_host_plan_activating
This error means that your product is incompatible with other products in the host plan. Refer to the build output for more details.
error_pbs_test_host_plan_deactivating
This error means that your product is incompatible with other products in the host plan. Refer to the build output for more details.
error_pbs_missing_theme_info_file
Your theme is missing the theme info filetheme_info.txtunder the root directory.
error_pbs_incomplete_theme_info
Your theme info filetheme_info.txtcontains malformed data structure. It should contain the product ID, hash and main file, all separated by new lines. For example:
Orders are created when a customer completes the checkout process, and they are visible to users with Admin and Shop Manager roles only. Each order is given a unique Order ID.
Order IDs are non-sequential as they use the default WordPress ID approach. For sequential order numbers, you can use Sequential Order Numbers Pro.
Order Statuses
An order also has aStatus. Order statuses let you know how far along the order is, starting with “Pending payment” and ending with “Completed.” The following order statuses are used:
Pending payment — Order received, no payment initiated. Awaiting payment (unpaid).
Failed— Payment failed or was declined (unpaid) or requires authentication (SCA). Note that this status may not show immediately and instead show asPendinguntil verified (e.g., PayPal).
Processing — Payment received (paid) and stock has been reduced; order is awaiting fulfillment. All product orders require processing, except those that only contain products which are both Virtual and Downloadable.
Completed — Order fulfilled and complete – requires no further action.
On hold — Awaiting payment – stock is reduced, but you need to confirm payment.
Canceled— Canceled by an admin or the customer – stock is increased, no further action required.
Refunded— Refunded by an admin – no further action required.
Authentication required— Awaiting action by the customer to authenticate the transaction and/or complete SCA requirements.
Visual Diagram to Illustrate Order Statuses
This visual representation follows an order through its statuses from “Pending payment” to “Completed”, “Canceled” or “Refunded.”
Arrangeorders inascendingordescendingorder byOrdernumber,DateorTotalby select the heading.
Note that the “Total” column doesnottake the refunded amount into consideration.
Click the order number and customer name to see theSingle Order page, where you can alsoEditorder details,Update Status, andAdd Notes. More details on that inViewing and Editing Single Orders.
Searching and Finding Orders
Orders can be found using the search box at the top right of the order list. Enter an order number, customer name, or other information shown in the order list such as address. ClickSearch ordersor tap return on your keyboard and search results will show a list of matching orders.
Previewing Orders
Order rows have aPreview“eye.”
Clicking Preview opens aModal, containing the order number, order status, billing details, payment method, shipping details, shipping method, items ordered, and the option to change the order status.
Order Statuses in the Overview
Order Statusesare color-coded and descriptive.
Canceled – Grey
Completed – Blue
Failed – Red
On Hold – Orange
Pending Payment – Grey
Processing – Green
Refunded – Grey
Order Actions
Hovering over an order Statusdisplays Notesmade on the order.
At the end of a row are shortcut buttons to quickly mark orders asProcessingorComplete.
Viewing and Editing a Single Order
From theSingle Orderpage not only can you view all order data, but also edit and update.
Change the order status.
Edit order items – modify the product, prices, and taxes.
Stock – Reduce and restore stock for an order
Order Actions – Email order details to customer (handy if manually creating an order for your customers) or Regenerate download permissions
Modify productMetato edit product variations by removing and adding meta
Apply coupons. You will need to know the coupon code to apply to the order. Coupon usage counts are tracked, and coupons can also be removed from orders. Note: the order must be unpaid for coupons to have an affect
Add fee. You can enter an amount or percentage to add a fee to an order. Negative fees will apportion taxes between all other items, and will not make the cart total go below zero
Order Details
Viewing Order Details
TheOrder Detailspanel you can view:
Order number
Payment details
Order date and time
Order status
Customer details:
Username and email, together with a link to view their profile and other purchases the customer may have had in the past
Billing details
Shipping details
Editing Order Details
Most of the details in this section can be updated and/or changes.
To change the date and time, use the dropdown date selector and the quantity selectors for the time.
To change the status, choose the right status in the dropdown.
To change the customer, select the current customer and search for the new customer.
Under “Billing” and “Shipping”, several other details can be changed. In order to do so, select the pencil icon next to each of them.
Under “Billing”, the following things can be changed:
Billing address — this can also be loaded from the customer’s profile by selecting “Load billing address”
Email
Phone number
Payment method and details
Under “Shipping”, the following things can be changed:
Shipping address — this can also be loaded from the customer’s profile or copied from the billing address
Customer provided note
Once you’ve made the necessary changes, selectUpdateto update the order.
Order Items and Totals
Viewing Order Items
The next panel on the order page is theOrder Itemspanel. This contains the product items, the shipping details, and the order summary.
Eachproduct item rowlists:
Product image
Product name
Single product Cost
Quantity
Total (Cost x Quantity, with discounts taken into consideration)
Taxes
Below that, theshipping detailsare displayed. This will include:
Shipping method
Boxed items
Total cost
Taxes
The last section contains anoverview of the order costs. This section will change if an order is refunded. By default, it will include:
Items subtotal — cost excluding tax
Coupon(s) — amount deducted based on the use of coupons; the coupons used are displayed left in this section
Shipping — the shipping cost for the order
Taxes — the amount of taxes for the whole order; this will be replaced by the tax code applied to the order
Order total — the total of the above costs
Finally, below the line, an overview of what is paid and the fees taken by payment gateways
Editing or Adding Order Items
Apart from refunding, order items can not be edited, unless the order status is “Pending payment”, or “On hold.”
Product items.Select thepencil iconnext to a product line to edit.
The following product items can be edited:
Add Meta— Add and remove meta to change product variable options.
Quantity— Number of items the customer is purchasing.
Total— Line price and line taxbefore pre-tax discounts.
Tax— Tax cost. For example, if a customer is tax-exempt you may want to remove the taxes.
Other actions.Next, you can do four actions at the bottom of this window:
Add item(s)— this will show you six new options:
Add product(s) — Add additional products to the order.
Add fee — Add an additional fee, such as gift wrapping.
Add shipping — Add a shipping cost. When you’ve done this, select the pencil icon to update the name, the method, the cost, and the tax.
Add tax — Add an additional tax code to every section in the order.
Cancel — Cancel if you do not want to make any changes.
Save — Save once the changes are made.
Once you’ve done this, you can selectRecalculateif you want to automatically perform new calculations based on store settings. This can be handy if you are adding or removing products, coupons, shipping methods, etc. Note that any tax changes that you’ve manually included will be removed as the tax settings in your store will apply based on the customer address.
Apply coupon— If your customer forgot to add the coupon could or you want to reward the customer before they pay, selecting this option will show a modal that allows you to apply a coupon code.
Refund— to refund the customer. For more information about Manual and Automatic Refunds, see WooCommerce Refunds.
Custom Fields
To add custom meta fields, use theCustom Fieldsmetabox:
Order Notes
TheOrder Notespanel displays notes attached to the order and can be used for storing event details, such as payment results or reducing stock levels, or adding notes to the order for customers to view. Some payment gateways also add notes for debugging.
The following note types are possible:
Purple: System status notices, such as payment gateway details.
Grey: General status updates, such as status changes or private notes. Customers do not see these notes but may receive notification of them, e.g., when the status changes from processing to completed, an email may be sent (depending on your settings).
Blue: Notes to the customer. Customers receive notes via email but can view them by viewing an order in their My account section.
Notes can be a powerful tool for communicating with customers or other store managers. Need to add a tracking number for shipping? Is stock delayed? Add a customer note, and they are automatically notified.
To add a note,
Use the textarea toadd the contentof the note.
SelectPrivate noteorNote to customerin the dropdown.
SelectAdd.
Manually Adding an Order
To add an order:
Go to:WooCommerce > Orders.
Use Add New at the top of the page. The Single Order page appears.
Inputcustomer details, add line items, apply coupons, apply fees and calculate totals. These are the same as theEditing or Adding Order Items.
Set a status for the new order, e.g., If it needs to be paid, use “Pending payment.”
Save.
Use theOrder Actionsdropdown to Email order details to the customer with payment instructions.
Paying for an Order
Orders that are “Pending payment” can be paid for through the payment link.
As the shop manager, you can find this link on the order overview:
If the customer is a Guest, anyone with the right link will be able to view the payment page and pay for the order.
If the customer is registered on your site,
Only this customer will be able to see the payment link once they are logged in.
The customer can also find the order in:My Account > Orders.
If the customer is assigned to the order, they will be asked to log in before paying:
If you are the store owner and wish to pay on behalf of the customer, consider usingUser Switching(not endorsed by WooCommerce.com) to log in to the customer’s account and complete the payment as them.
Removing Personal Data
Starting with WooCommerce 3.4+, it is possible to remove customer data.
Go to:WooCommerce > Settings > Accounts & Privacy.
EnableAllow personal data to be removed in bulk from orders.
Save changes.
This option is now available for orders:
Go to:WooCommerce > Orders.
Select the ordersthat need personal data removed.
SelectBulk Actions > Remove personal data.
SelectApply.
Please note, that once you press Apply this will remove personal data with no further warning. Orders will appear on the Orders screen like this:
On an individual order, data is updated like this:
Failed, pending, and canceled orders which get cleaned up will be moved to the trash.
Completed orders which get cleaned up will be anonymized so sales stats are unaffected (as above).
Inactive accounts will be deleted. An inactive account is one which has not been logged in to, or which has not placed orders, for the specified time.
Personal data removalcan be automatically associated with account erasure requests. WordPress allows deleting user details upon request viaTools > Erase Personal Data. This removal can now also be associated with the orders of this user.
Go to:WooCommerce > Settings > Accounts & Privacy.
UnderAccount erasure requests:
EnableRemove personal data from orders on request, if you also want to remove order data when this is done
EnableRemove access to downloads on request, if the customer should no longer access the download links once their personal details have been removed.
Personal data retentioncan also be automated.
Go to:WooCommerce > Settings > Accounts & Privacy
UnderPersonal data retention, set thresholds for inactive accounts and for orders with different statuses.
Save changes.
If enabled, this cleanup will run via a daily cron job. Inactive accounts are tracked using metadata, and only subscribers/customer accounts are removed.
Multi-Site Orders
Starting with WooCommerce 3.4+ there is now a widget that appears under Dashboard that shows order information from across all sites. You can click on an order to be taken to the details of the order on that site.
Troubleshooting
Understanding Order Statuses in Relation to Payment Gateways
Awaiting payment – stock is reduced, but you need to confirm payment
Usually seen with payment methods when you need to manually confirm, such as BACS (bank transfer) or cheque.
You’ll also see this when the gateway is set to authorize instead of capture a charge: the shop owner will need to manually switch the status to processing.
Order received (unpaid).
Most gateways will report back and set the order status toProcessing(payment successful) orFailed(payment unsuccessful). If the shop never receives either signal, it keeps the status onPending.
This tends to be a misconfiguration of payment notification URLs or a plugin conflict.
Payment received and stock has been reduced- the order is awaiting fulfillment. All product orders require processing, except those with only products that are bothdigital and downloadable.
If the payment has been successful and the order does not contain Digital or Downloadable products, the order will be set toProcessing.
This is the shop owner or warehouse’s cue to ship the order and manually mark it ascompleted.
Order fulfilled and complete – requires no further action
These generally aren’t interesting because everything has gone correctly.
Payment failed or was declined (unpaid).
The order can be manually canceled, but this status can come up if the payment window has expired. It can happen for a few reasons:
order was abandoned before payment was completeThe hold stock window expired without a response
Same reasons asPending
Customer must complete requirements for SCA.
It can occur when:
a new customer makes a purchase
an existing subscription renews
Questions
Do you still have questions and need assistance?
Get in touchwith a Happiness Engineer via our Help Desk. We provide expert priority supportfor WooCommerce.com and Jetpack customers but not other third-party plugins.