Skip to content

Instantly share code, notes, and snippets.

View MasterHans's full-sized avatar

Alexander Suvorov MasterHans

  • Russia
View GitHub Profile
public function getKeyFromUrl($url)
{
$index = mb_strpos($url, '.com');
return mb_substr($url, $index+4);
}
$this->criteria->params[':cli'] = $this->clientId;
$this->criteria->params[':cor'] = $this->correspondenceAccountId;
$this->criteria->params[':cdi'] = $this->creditDebitIndicator == 'K' ? 'D' : 'K'; // Invert logic
$this->criteria->params[':invcdi'] = $this->creditDebitIndicator;
$this->criteria->order = 'd_data ASC, d_dok ASC';
c.sendEmail = function () {
c.savingData = true;
if (_.isUndefined(c.model.toEmail) && model.templateId === 7) {
if (model.agreementIds.length === 1 && model.agreementIds[0] === 0) {
//get all employees
personnelEmployee.fetchAllWorkingEmployees()
.then(function (data) {
console.log(data);
prepareAndSend();
})
// add text to template in woocommerce_email_before_order_table hook
function filter_woocommerce_email_before_table( $order, $is_admin_email ) {
// make filter magic happen here...
echo '<h1><strong>Discount used </h1>';
};
add_action( 'woocommerce_email_before_order_table', 'filter_woocommerce_email_before_table', 10, 3 );
@MasterHans
MasterHans / AngularJs - Get input by angular.element
Created June 21, 2022 15:10
AngularJs - Get input by angular.element
var myElement = angular.element($document[0].querySelector('.form-control.input-sm.ng-valid.ng-not-empty.ng-dirty.ng-valid-parse.ng-touched'));
myElement.trigger('hideCalendar.daterangepicker');
@MasterHans
MasterHans / Wordpress - switch on log writing
Created June 19, 2022 13:52
Wordpress - switch on log writing
/**
* enable log writing
* // Enable WP_DEBUG mode
define( 'WP_DEBUG', true );
// Enable Debug logging to the /wp-content/debug.log file
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
*/
if (!function_exists('write_log')) {
@MasterHans
MasterHans / woocomerce - add validation on checkout field blur - out of input in JS
Created June 19, 2022 13:32
woocomerce - add validation on checkout field blur - out of input in JS
add_action( 'wp_footer', 'ybc_javascript_validation' );
function ybc_javascript_validation(){
if( !is_checkout() ) return;
?> <script>jQuery(function($){
$('body').on('blur change', '#billing_birthday', function(){
// alert($(this).val());
var formRow = $(this).parents('.form-row');
// if( /\d/.test( $(this).val() ) ) {
add_filter( 'woocommerce_checkout_fields', 'pulse_checkout_fields_validate_birthdate', 9999 );
function pulse_checkout_fields_validate_birthdate( $fields ) {
$cart = WC()->cart->get_cart();
foreach ( $cart as $cart_item ) {
$variation = wc_get_product($cart_item['variation_id']);
$variationFormattedName = $variation->get_formatted_name();
$cartItemVariationIsChildrenRace = (strpos($variationFormattedName, 'Детский')>0);
write_log($cartItemVariationIsChildrenRace);
@MasterHans
MasterHans / Add filter in Backend
Created October 26, 2021 13:36
Add filter in Backend to DataProvider
other.country.controller.js:
c.possibleCountries = {
config: {},
filter: {
countryType: 0
},
data: [],
};
@MasterHans
MasterHans / Add filter to grid through the FrontEnd
Created October 26, 2021 13:30
Add filter to grid through the FrontEnd
_.set(c.possibleCountries.filter, ['filters', 'groupOp'], 'AND');
//exclude selected countries
_.set(c.possibleCountries.filter, ['filters', 'rules', 'id'], {
field: 'id',
op: 'ni',
data: c.model.countriesTypeIds
});
//set filter on EU countries
_.set(c.possibleCountries.filter, ['filters', 'rules', 'typeId'], {
field: 'typeId',