Commit 4c15e99c authored by Koinova Angelika's avatar Koinova Angelika

update

parent edf35a53
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
"drupal/admin_toolbar": "^2.4", "drupal/admin_toolbar": "^2.4",
"drupal/commerce": "^2.30", "drupal/commerce": "^2.30",
"drupal/commerce_cart_api": "^1.5", "drupal/commerce_cart_api": "^1.5",
"drupal/commerce_stock": "^1.0",
"drupal/config_ignore": "^2.3", "drupal/config_ignore": "^2.3",
"drupal/core": "^9.1", "drupal/core": "^9.1",
"drupal/core-composer-scaffold": "^9", "drupal/core-composer-scaffold": "^9",
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "d42bf3cbb31a5025595460282d7ca21e", "content-hash": "8c1b0ee6d799c238a8d91a6f63e5569d",
"packages": [ "packages": [
{ {
"name": "asm89/stack-cors", "name": "asm89/stack-cors",
...@@ -2405,6 +2405,77 @@ ...@@ -2405,6 +2405,77 @@
"source": "https://git.drupalcode.org/project/commerce" "source": "https://git.drupalcode.org/project/commerce"
} }
}, },
{
"name": "drupal/commerce_stock",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://git.drupalcode.org/project/commerce_stock.git",
"reference": "8.x-1.0"
},
"dist": {
"type": "zip",
"url": "https://ftp.drupal.org/files/projects/commerce_stock-8.x-1.0.zip",
"reference": "8.x-1.0",
"shasum": "16d267a34122a8c87a567c5eae5619b023288f5f"
},
"require": {
"drupal/commerce": "~2.0",
"drupal/commerce_order": "*",
"drupal/commerce_product": "*",
"drupal/core": "^8 || ^9"
},
"require-dev": {
"drupal/commerce_product": "*",
"drupal/commerce_stock_local": "*"
},
"type": "drupal-module",
"extra": {
"drupal": {
"version": "8.x-1.0",
"datestamp": "1642166789",
"security-coverage": {
"status": "covered",
"message": "Covered by Drupal's security advisory policy"
}
}
},
"notification-url": "https://packages.drupal.org/8/downloads",
"license": [
"GPL-2.0+"
],
"authors": [
{
"name": "guy_schneerson",
"homepage": "https://www.drupal.org/user/755184"
},
{
"name": "iAugur",
"homepage": "https://www.drupal.org/user/750068"
},
{
"name": "olafkarsten",
"homepage": "https://www.drupal.org/user/352745"
},
{
"name": "rfay",
"homepage": "https://www.drupal.org/user/30906"
},
{
"name": "rszrama",
"homepage": "https://www.drupal.org/user/49344"
}
],
"description": "Provides a stock management framework based on rules to manage stock levels of commerce products",
"homepage": "https://www.drupal.org/project/commerce_stock",
"keywords": [
"Drupal"
],
"support": {
"source": "http://cgit.drupalcode.org/commerce_stock",
"issues": "http://drupal.org/project/issues/commerce_stock"
}
},
{ {
"name": "drupal/commerce_store", "name": "drupal/commerce_store",
"version": "2.30.0", "version": "2.30.0",
......
...@@ -4,3 +4,5 @@ modal.from.js: ...@@ -4,3 +4,5 @@ modal.from.js:
js/modal_form.js: {} js/modal_form.js: {}
dependencies: dependencies:
- core/drupal.dialog.ajax - core/drupal.dialog.ajax
- core/jquery
- core/jquery.once
...@@ -7,26 +7,33 @@ ...@@ -7,26 +7,33 @@
use Drupal\Component\Utility\Html; use Drupal\Component\Utility\Html;
use Drupal\Core\Ajax\AjaxResponse; use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\AlertCommand; use Drupal\Core\Ajax\AlertCommand;
use Drupal\Core\Ajax\InvokeCommand;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\ajaxform\AjaxBuySubmit; use Drupal\ajaxform\AjaxBuySubmit;
function ajaxform_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) { function ajaxform_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
//$id = $form['#wrapper_id'];
$build_ifo = $form_state->getBuildInfo(); $build_ifo = $form_state->getBuildInfo();
$id = $build_ifo['base_form_id']; $id = $build_ifo['base_form_id'];
if (!empty($id)){ if (!empty($id)){
if($id == 'commerce_order_item_add_to_cart_form') if($id == 'commerce_order_item_add_to_cart_form')
{ {
$form['actions']['submit']['#ajax'] = [ $form['actions']['submit']['#ajax'] = [
'callback' => 'Drupal\ajaxform\AjaxBuySubmit::ajaxSubmitCallback', 'callback' => 'ajaxSubmitCallback',
// 'callback' => 'your_module_ajax_callback',
'event' => 'click', 'event' => 'click',
'progress' => [
'type' => 'throbber',
],
]; ];
$form['#attached']['library'][] = 'ajaxform/modal.from.js';
} }
} }
}
function ajaxSubmitCallback(array &$form, FormStateInterface $form_state) {
$ajax_response = new AjaxResponse();
$ajax_response->addCommand(new InvokeCommand(NULL, 'myTest', ['some Var']));
return $ajax_response;
} }
(function ($, Drupal, drupalSettings) { (function($) {
$.fn.myTest = function(data) {
'use strict';
Drupal.behaviors.ajaxform_modal_form_js = {
attach: function (context, settings) {
$('.button--add-to-cart', context).click(function () {
// 1. Создаём новый XMLHttpRequest-объект
let xhr = new XMLHttpRequest(); let xhr = new XMLHttpRequest();
// 2. Настраиваем его: GET-запрос по URL // 2. Настраиваем его: GET-запрос по URL
...@@ -50,10 +43,5 @@ ...@@ -50,10 +43,5 @@
}); });
frontpageModal.showModal(); frontpageModal.showModal();
}; };
};
}); })(jQuery);
}
}
} (jQuery, Drupal, drupalSettings));
<?php
/**
* @file
* Contains \Drupal\ajaxform\AjaxBuySubmit
*/
namespace Drupal\ajaxform;
use Drupal\Component\Utility\Html;
use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\AlertCommand;
use Drupal\Core\Ajax\HtmlCommand;
use Drupal\Core\Form\FormStateInterface;
/**
* Class AjaxContactSubmit
* @package Drupal\ajaxform\AjaxBuySubmit
*/
class AjaxBuySubmit {
/**
* Ajax form submit callback.
*
* @param array $form
* @param \Drupal\Core\Form\FormStateInterface $form_state
*/
public function ajaxSubmitCallback(array &$form, FormStateInterface $form_state) {
// $ajax_response = new AjaxResponse();
// $ajax_response->addCommand(new AlertCommand('Спасибо за заполнение'));
// return $ajax_response;
return [
'#attached' => [
'library' => [
'ajaxform/modal.from.js',
],
],
];
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment