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 | |
/** | |
* Filter hook wc_specter_internal_comment | |
* Modify internalComment sent to Specter on new order submission. | |
* internalComment is displayed in Specter for the merchant but not on the order/packing slip that can be sent to the customer. | |
* | |
**/ | |
add_filter( 'wc_specter_internal_comment', 'my_wc_specter_internal_comment', 10, 2 ); | |
function my_wc_specter_internal_comment( $customer_note, $order_id ) { | |
// Tänk på att $customer_note kan innehålla kundens notering från kassan |
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 | |
class WCML_Klarna_Gateway{ | |
public function add_hooks(){ | |
add_filter( 'wcml_multi_currency_ajax_actions', array( $this, 'ajax_action_needs_multi_currency' ) ); | |
} |
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 | |
* Filter the country sent to Klarna. | |
**/ | |
add_filter( 'klarna_country', 'my_klarna_country' ); | |
function my_klarna_country( $country ) { | |
if( WC()->customer ) { | |
if ( 'EUR' == get_woocommerce_currency() ) { |
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
/** | |
* WooCommerce - Klarna payment gateway | |
* Filter Create order for making date of birth a mandatory field in Klarna Checkout iframe. | |
**/ | |
// New order ($create) | |
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
add_filter( 'woocommerce_get_checkout_url', 'krokedil_change_checkout_url', 30 ); | |
function krokedil_change_checkout_url( $url ) { | |
$allowed_countries = array( 'SE', 'NO', 'FI', 'DE', 'DK', 'AT', 'UK', 'US' ); | |
$customer_country = WC()->customer->shipping_country; | |
if( !in_array( $customer_country , $allowed_countries ) ) { | |
$url = wc_get_page_permalink( 'checkout' ); | |
} | |
return $url; |
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 | |
/** | |
* Trim zeros in price decimals in WooCommerce. | |
* For instance $200.00 is displayed as $200. | |
**/ | |
add_filter( 'woocommerce_price_trim_zeros', '__return_true' ); |
NewerOlder