This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* WooCommerce | |
* -------------- | |
* | |
* Display cart total weight on the cart page | |
* | |
*/ | |
add_action('woocommerce_cart_collaterals', 'myprefix_cart_extra_info'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* WooCommerce - Klarna payment gateway | |
* Don't display the Klarna Checkout form if cart is less than the specified amount. | |
* Useful when you only want to have KCO as an available payment method for orders above a specific order amount. | |
* | |
**/ | |
// Check to see if the KCO checkout should be displayed | |
add_filter('klarna_kco_checkout', 'my_klarna_kco_checkout'); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Klarna Checkout Extra Fields | |
* Plugin URI: http://krokedil.com | |
* Description: Add custom input fields to Klarna Checkout page. Added via shortcode [woocommerce_klarna_checkout_extra_fields]. Saved as post_meta to the order directly on .blur via ajax. | |
* Version: 1.1 | |
* Author: Krokedil | |
* Author URI: http://krokedil.com | |
* License: GPL-2.0+ | |
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* WooCommerce - Klarna payment gateway | |
* Filter Create order for disabling autofocus of email field. | |
**/ | |
// New order ($create) | |
add_filter('kco_create_order', 'my_kco_create_order'); | |
function my_kco_create_order( $create ) { | |
$create['gui']['options'] = array('disable_autofocus'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'wc_specter_send_custom_product_data', 'my_custom_product_data', 10, 3 ); | |
function my_custom_product_data( $params, $product, $is_variation = false ) { | |
/** | |
* $params is the product data stored as an array. | |
* $product is the product object. Product variation object if this is a product variation. | |
* $is_variation is true/false depending on if this is a product variation or not. | |
*/ | |
// Unset articleType type so we don't send that to Specter when product is updated in WooCommerce. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Add a cehckbox to KCO iframe that is required to check before the purchase can be completed | |
add_filter('kco_create_order', 'krokedil_add_required_checkbox'); | |
add_filter('kco_update_order', 'krokedil_add_required_checkbox'); | |
function krokedil_add_required_checkbox( $create ) { | |
$create['options']['additional_checkbox']['text'] = 'I agree to the <a href="https://example.com/terms" target="_blank">terms</a> and data policy.'; | |
$create['options']['additional_checkbox']['checked'] = false; | |
$create['options']['additional_checkbox']['required'] = true; | |
return $create; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Filter hook wc_specter_published_comment | |
* Modify publishedComment sent to Specter on new order submission. | |
* publishedComment is displayed on the order/packing slip that can be sent to the customer. | |
* | |
**/ | |
add_filter( 'wc_specter_published_comment', 'my_wc_specter_published_comment', 10, 2 ); | |
function my_wc_specter_published_comment( $published_comment, $order ) { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* WooCommerce - Klarna payment gateway | |
* Only accept purchases from customer over 18 years of age. | |
**/ | |
// Edit the order data sent to Klarna to make 'Date of birth' a mandatory field in the KCO iframe | |
add_filter('kco_create_order', 'my_kco_create_order'); | |
function my_kco_create_order( $create ) { | |
$create['options']['national_identification_number_mandatory'] = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* WooCommerce - Klarna payment gateway (Klarna Checkout) | |
* Filter Create order & Update order sent to Klarna to change mandatory fields in the checkout iframe (Date of birth & Title). | |
* Also fetching order data returned from Klarna after a successful payment and updating the local WooCommerce order. | |
* | |
* Learn more about available params in order object sent to Klarna here: | |
* V2 - https://developers.klarna.com/en/se/kco-v2/checkout-api | |
* V3 - https://developers.klarna.com/api/#checkout-api | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Specter for WooCommerce | |
* Filter the payTypeIdentifier sent to Specter | |
* | |
**/ | |
add_filter('wc_specter_pay_type_identifier', 'my_wc_specter_pay_type_identifier', 10, 2); | |
function my_wc_specter_pay_type_identifier( $paytype, $order_id ) { | |
// Switches the paytype to D (cash payment) for all orders that uses Cach on Delivery (originally paytype P in the extension) as the payment method. |
NewerOlder